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)

Preferred Member

10+ Year Member

joined:Sept 7, 2003
posts: 383
votes: 0

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

joined:July 24, 2001
votes: 0

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)

Junior Member

10+ Year Member

joined:May 31, 2006
votes: 0

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)

New User

10+ Year Member

joined:Feb 6, 2008
votes: 0

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