Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Echo not working as expected.

Driving me crazy



4:29 pm on Mar 11, 2008 (gmt 0)

10+ Year Member

I have a script that is a mixture of php and html code. I have a variable that is pulled from a database using the following query

SELECT city FROM geo where id=1234

If I echo the result out in the php portion of the script using

echo $row['city'];

The result is echoed fine, however if I try to echo it out in the html part of the script using the following

<p><?php echo $row['city'];?></p>

No result is returned.


4:50 pm on Mar 11, 2008 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

I doubt echo is the problem, I would lean more towards whether the var is set or unset

how is the value of $row being set?
are you using both of those in the exact same spot in the code?
if not what is happening to $row between one and the other?


4:54 pm on Mar 11, 2008 (gmt 0)

5+ Year Member

If you just wanted to double check the echo, you could always make it <?php echo 'City: '.$row[city]; ?>. That way you'd know the echo is working but the variable is empty.


4:58 pm on Mar 11, 2008 (gmt 0)

5+ Year Member

Are you using an include for the script generating the variable by any chance?

Featured Threads

Hot Threads This Week

Hot Threads This Month