Forum Moderators: coopster

Message Too Old, No Replies

Weird Echo Statement

I know this is probably simple...

         

TheSpeshulK

5:18 am on Jan 3, 2008 (gmt 0)

10+ Year Member



I'm pretty new at PhP programming and I have not run into this before. I am trying to just echo some html code to a dynamically created page but it seems like I'm missing something simple. I've tried using variables to see if the echo statement didn't like the quotes but that didn't change anything (I didn't think it would). I've looked at this for a while and can't figure out what the problem is. Could someone please give me some advice?
Here is the code:

<?php
require ('dbconnect.inc');
$query_state = "select state from States;";
$result_state = mysql_query($query_state);
$query_city = "select city from Cities;";
$result_city = mysql_query($query_city);
$query_venue = "select venue from Venues;";
$result_venue = mysql_query($query_venue);

if (mysql_num_rows($result_state) == 0 ¦ mysql_num_rows($result_city) == 0 ¦ mysql_num_rows($result_venue) == 0){
echo 'nothing here...';
}
else{
while ($row1 = mysql_fetch_assoc($result_state) ¦ ($row2 = mysql_fetch_assoc($result_city) ¦ ($row3 = mysql_fetch_assoc($result_venue)){
echo "<tr>";
$out = "<td width='33%' align='center' valign='top'>"."<div align='center'>";
echo $out;
echo $row1['state'];
echo "</td>";

$out = "<td width='33%' align='center' valign='top'>"."<div align='center'>";
echo $out;
echo $row2['city'];
echo "</td>";

$out = "<td width='34%' align='center' valign='top'>"."<div align='center'>";
echo $out;
echo $row3['venue'];
echo "</td></tr>";
}
}
?>

and here is what I am seeing:

"; $out = ""; $out = ""; $out = ""; } }?>
Some Artist State Some Artist City Some Artist Venue
"."
"; echo $out; echo $row1['state']; echo "

"."
"; echo $out; echo $row2['city']; echo "

"."
"; echo $out; echo $row3['venue']; echo "

each appear in the row they should

Habtom

5:40 am on Jan 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This doesn't seem to be a PHP syntax problem.

Do you have PHP running? Is your file saved in php recognizable extension, like .php?

adb64

7:10 am on Jan 3, 2008 (gmt 0)

10+ Year Member



I think PHP is running as I see some output written like 'Some Artist State Some Artist City Some Artist Venue' which is not in the code.
But it looks like you put a single quote where a double quote is needed or vice versa. But I can't find it in the code above.
But what do you see when you look at the source in the browser. Do you see the code exactly as in the PHP source file, with the <?php tag at the beginning. If so, then indeed PHP is not running as Habtom mentioned.

And welcome to Webmaster World

TheSpeshulK

11:54 am on Jan 3, 2008 (gmt 0)

10+ Year Member



Yup the .php was the problem. I was having the page be created as a .html. I have changed it to .php and it is working fine now. i knew it had to be something small like that. Thanks for both of your help.