Antun
Antun

Reputation: 3

PHP Comment box inside Sidebar show number 1, How to get rid of it?

I have problem with my (made with tutorial) PHP comment box.

The problem is this number 1. I think that problem is in last code, but as I am beginner I don't know where is problem.

I'm posting all 3 php files without header and footer file.

PrtSc of problem on page

Source code in chrome of page

This is full code in php....

First php file

<?php   

    $title = "FilmoviRecenzije";
    $content = '


    <img src="Slike_filmovi/novo_Mockingjay2.jpg" class="imgLeft"/>
    <h2>The Hunger Games: Mockingjay - Part 2 (2015)</h2>
    <p><i>"Žanr: Avantura, Znanstvena fantastika"</i></p>
    <p>Režija: Francis Lawrence<p>
    <h4>    
    U grand finalu spektakularne kino-hit franšize Igre gladi Katniss Everdeen (Jennifer Lawrence),
    nakon što je postala vođa masovne pobune potlačenih, zajedno sa Distriktom 13 pokreće 
    sveopću revoluciju protiv autokratskog Kapitola. Katniss nastavlja svoju ulogu heroja
    koji se u nevjerojatnoj bitci za preživljavanje bori za svoj narod! 
    </h4>

    <dev class="videoCenter">
    <iframe width="720" height="405" src="https://www.youtube.com/embed/n-7K_OjsDCQ" frameborder="0" allowfullscreen></iframe>
    </dev>
    ';


    include ('Template_Mockingjay2.php');

    ?>

Next file which is connected through "include" is:

<?php include('Header.php'); ?>
        <div id="wrapper">
            <div id="banner">

        </div>

        <nav id="navigation">
            <ul id="nav">
                <li><a href="Pocetna.php">Početna </a></li>
                <li><a href="Novi_Filmovi.php">Novi Filmovi</a></li>
                <li><a href="Kontakt.php">Kontakt</a></li>
            </ul>
        </nav>

        <div id="content_area">
            <?php echo $content; ?>
        </div>

        <div id="sidebar">

            <?php echo include('novo_Mockingjay2_komentar.php');  ?>    

        </div>


<?php include ("Footer.php"); ?>

And last file for Mysql, same included is:

<?php
mysql_connect("localhost","root","");
mysql_select_db("db_komentari");
if (isset($_POST['Ime']) && isset($_POST['Komentar'])){
    // $Ime = isset($_POST['Ime']) ? $_POST['Ime'] : 
    $Ime = $_POST['Ime'];
    $Komentar = $_POST['Komentar'];
    $submit = $_POST['submit'];

    $dbLink = mysql_connect("localhost","root","");

    if($submit)
    {
    if($Ime&&$Komentar)
    {
    $insert=mysql_query("INSERT INTO novo_mockingjay2 (Ime,Komentar) VALUES ('$Ime','$Komentar') ");
    echo "<meta HTTP-EQUIV='REFRESH' content='0; url=novo_Mockingjay2.php'>";
    }
    else
    {
    echo "Molim Vas ispunite oba polja";
    }
    }
    }
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Komentari</title>


<center>
<form action="novo_Mockingjay2.php" method="POST">
<table>
    <tr><td>Ime: <br><input type="text" name="Ime"/></td></tr>
    <tr><td colspan="2">Komentar: </td></tr>
    <tr><td colspan="5"><textarea name="Komentar" rows="1" cols="18"></textarea></td></tr>
    <tr><td colspan="2"><input type="submit" name="submit" value="Objavi"></td></tr>
</table>
</form>

<?php
    $dbLink = mysql_connect("localhost","root","");


    $getquery=mysql_query("SELECT * FROM novo_mockingjay2 ORDER BY ID DESC");
    while($rows=mysql_fetch_assoc($getquery))
    {
    $ID=$rows['ID'];
    $Ime=$rows['Ime'];
    $Komentar=$rows['Komentar'];
    echo $Ime . ':<br/>' . $Komentar . '<br/>' . '<br/>' . '<hr size="4"/>';}

?>

Thank You in Advance!

Upvotes: 0

Views: 31

Answers (1)

u_mulder
u_mulder

Reputation: 54831

As include language construct returns 1 on successful file including - this value is passed to your echo, so line:

echo include('novo_Mockingjay2_komentar.php');

means - include file, execute it and echo the result of inclusion. As result is 1 - it's echo'ed.

Change it to:

include('novo_Mockingjay2_komentar.php'); // without echo

Upvotes: 1

Related Questions