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
spacebiscuit
Forum Contributor
Posts: 390 Joined: Mon Mar 07, 2005 3:20 pm
Post
by spacebiscuit » Tue May 18, 2010 3:17 pm
Hi,
I'm trying to write the row of an mysql quesry result into a session array:
Code: Select all
$_SESSION[data]=mysql_fetch_row($result);
I'm then trying to write the data as follows:
However that gives me:
What am I doing wrong?
Thanks in advance,
Rob.
flying_circus
Forum Regular
Posts: 732 Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR
Post
by flying_circus » Tue May 18, 2010 3:31 pm
Use one of the following to see what your array looks like
spacebiscuit
Forum Contributor
Posts: 390 Joined: Mon Mar 07, 2005 3:20 pm
Post
by spacebiscuit » Tue May 18, 2010 3:33 pm
It seems I was missing the quotations:
this works:
How do I output the variable using echo though:
If I include the quotations I get a string escape error!
Thanks for your help.
Rob.
flying_circus
Forum Regular
Posts: 732 Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR
Post
by flying_circus » Tue May 18, 2010 4:44 pm
What happens when you try the following?
Code: Select all
if($result)
$_SESSION['data'] = mysql_fetch_row($result);
echo $_SESSION['data'][0];