problem with echoing a fetch_assoc variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
geantbrun
Forum Newbie
Posts: 2
Joined: Sun Apr 19, 2009 12:36 pm

problem with echoing a fetch_assoc variable

Post by geantbrun »

Hi,
I have a variable y that is a result of a fetch_assoc command:
$y = @$x->fetch_assoc();

Variable $y contains one field 'foo'. Now I want to echo it, problem is that it doesn't work:

echo "$y['foo']"; //produces a blank plage, because of a syntax error I suppose

echo '$y["foo"]'; //echoes litteraly $y["foo"]

Any solution apart this one?
$bar = $y['foo'];
echo "$bar";

best regards,
Patrick
Post Reply