Echo dissappears after adding another one?

Discussion in 'PHP' started by ronnyrtg, Aug 17, 2007.

  1. #1
    Hi I have just started learning php a few weeks ago and was happily modifying my website until i met with this really confusing problem that has been troubling me all day long.I created a Layout Table and drew 3 Layout cell (I'm using Dreamweaver).Then i did three different php scripts and pasted it to the 3 cells.Problem is, when i pasted the 3rd php script in the 3rd Cell,the php script at the 2nd cell wont show up!If i take out the 2nd php script in the 2nd cell the 3rd script will be visible!these two scripts just can't coexist with each other and i can't seem to find what went wrong anywhere... :(

    This code is before i insert the 3rd php script:



    <br>
    <?php
    echo $row[search]
    ?>

    <!--<table class="wd750" align="center">
    <tr>
    <td class="usp"><span class="tagline">$row[banner]</td>

    </tr>
    </table>
    -->

    <table class="wd750" align="center">
    <tr>
    <td class="hrhdlL"><span class="tagline"><strong>Browse&nbsp;by&nbsp;category</strong></span></td>
    </tr>
    </table>
    <hr>
    <table width=100% cellspacing="5" cellpadding="0">
    <!--DWLayoutTable-->
    <tr>
    <td width="138" height="157" valign="top"><p>&nbsp;</p>
    </td>
    <td width="657" valign="top">
    <table width=100%>
    <!--DWLayoutTable-->
    <tr>
    <td height="21" valign="top">
    <br> <?php
    echo $row[displaycat]
    ?></td>
    </tr>
    <tr>
    <td width="634" height="128">&nbsp;</td>
    </tr>





    <!--DWLayoutTable-->
    </table></td>
    <td width=152 valign="top" nowrap><p class="tagline"></p>
    <p class="tagline"> </p>
    <?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("2u2ia", $con);

    $result = mysql_query("SELECT * FROM textad limit 10");

    while($row = mysql_fetch_array($result))
    {
    $siteurl = $row["link"];
    $sitetext = $row["text"];
    echo ("<a href='http://$siteurl'>$sitetext </a>");
    echo "<br />";
    echo "<br />";

    }

    mysql_close($con);
    ?>
    <p>&nbsp; </p> <p>&nbsp; </p></td>
    </tr>
    </table>
    =========================================================
    and this is after i added the 3rd script:



    <br>
    <?php
    echo $row[search]
    ?>

    <!--<table class="wd750" align="center">
    <tr>
    <td class="usp"><span class="tagline">$row[banner]</td>

    </tr>
    </table>
    -->

    <table class="wd750" align="center">
    <tr>
    <td class="hrhdlL"><span class="tagline"><strong>Browse&nbsp;by&nbsp;category</strong></span></td>
    </tr>
    </table>
    <hr>
    <table width=100% cellspacing="5" cellpadding="0">
    <!--DWLayoutTable-->
    <tr>
    <td width="138" height="157" valign="top"><p>&nbsp;<?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("2u2ia", $con);

    $result = mysql_query("SELECT * FROM bannerad ");

    while($row = mysql_fetch_array($result))
    {
    $siteurl = $row["banlink"];
    $filename = $row["banname"];
    $adid = $row["bannerid"];

    echo ("<a href='http://$siteurl'><img border=\"2\" src=\"banners/$filename\" width=\"100\" height=\"50\"></a>");
    }

    mysql_close($con);
    ?></p>
    </td>
    <td width="657" valign="top">
    <table width=100%>
    <!--DWLayoutTable-->
    <tr>
    <td height="21" valign="top">
    <br> <?php
    echo $row[displaycat]
    ?></td>
    </tr>
    <tr>
    <td width="634" height="128">&nbsp;</td>
    </tr>





    <!--DWLayoutTable-->
    </table></td>
    <td width=152 valign="top" nowrap><p class="tagline"></p>
    <p class="tagline"> </p>
    <?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("2u2ia", $con);

    $result = mysql_query("SELECT * FROM textad limit 10");

    while($row = mysql_fetch_array($result))
    {
    $siteurl = $row["link"];
    $sitetext = $row["text"];
    echo ("<a href='http://$siteurl'>$sitetext </a>");
    echo "<br />";
    echo "<br />";

    }

    mysql_close($con);
    ?>
    <p>&nbsp; </p> <p>&nbsp; </p></td>
    </tr>
    </table>
    =======================================================
    Somebody help me...... :(
     
    ronnyrtg, Aug 17, 2007 IP
  2. YIAM

    YIAM Notable Member

    Messages:
    2,480
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    #2
    Just I can say that you missed ; twice;

    May be that is the problem.

    echo $row[search] ;


    echo $row[displaycat] ;
     
    YIAM, Aug 17, 2007 IP
  3. Grumps

    Grumps Peon

    Messages:
    592
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What YIAM says should be the case. You need semi colon to end a statement.

    Echo will not overlap. It will list everything out. Example:

    
    echo "My";
    echo " name";
    echo " is";
    
    PHP:
    The output will be as follow
    
    My name is
    
    Code (markup):
     
    Grumps, Aug 17, 2007 IP
  4. supperman

    supperman Peon

    Messages:
    22
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    no,friend,i think there is another problem

    check $row[banner]
    you didn't use <? ?> and you didn't use echo();
    so it's uselss.
    please be patient,when you begin to step into the php world
    hope this helps.

    /s
     
    supperman, Aug 17, 2007 IP
  5. ronnyrtg

    ronnyrtg Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I have put the semicolons but the problem is still there. for the $row[banner] i already put <!-- and --> because i don't want to display it at this moment...
    Is it possible that the 2nd php script used up the space and the 3rd php script was unable to squeeze in? I have attached the screenshots for
    1)before i pasted the 3rd php script
    2) and after i pasted the 3rd php script
    at wwwsabahholidaycom/why.html
     
    ronnyrtg, Aug 19, 2007 IP
  6. ronnyrtg

    ronnyrtg Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I finally managed to get all the php scripts to appear. For this part "<?php
    echo $row[displaycat]?>" i had to make a direct connection to the mysql database like the other two scripts.Thanks guys for pointing out my mistakes >v<
     
    ronnyrtg, Aug 20, 2007 IP