On Mon, June 19, 2006 10:26 am, Alex Major wrote: > Hi there. > I'm working my way through a new script, but I've stumbled into a > problem. > Some data that I've set into a session, won't be processed by part of > my php > code, but then later on in the page I can get the session value to > output. > > Also, just so that its clear, the mysql code is correct (I can put it > into > phpmyadmin and get results from it. > > Heres the code (this code is 'included' in another page, where the > session > originates and session_start(); is set.) > > <?php > // Lets see how much the person has at the moment. > $current_resource_query = "SELECT food, wood, stone, gold, > population > FROM game_resources WHERE user_id = '".$_SESSION['user_id']."'"; First, figure out if the query you THINK you are sending is what you are sending: echo $current_resource_query; Yes, I know you said you did this, but keep it in here for debugging for awhile. Most crucial, is to make SURE the 'user_id' really is what you expect, and not just glance at the 32-character gobbledy-gook and say "Yeah, that's right." > $current_resource_result = mysql_query($current_resource_query); Next, you HAVE to do error-checking with mysql_error(); > $current_resource = mysql_fetch_assoc($current_resource_result); > > ?> > <table width="100%" cellspacing="1" cellpadding="1"> > <tr> > <td colspan="5"><?php $userid ?> <?php $_SESSION['username'] > ?></td> > </tr> > <tr> > <td width="20%">Food: <?php $current_resource['food'] ?></td> > <td width="20%">Wood: <?php $current_resource['wood'] ?></td> > <td width="20%">Stone: <?php $current_resource['stone'] ?></td> > <td width="20%">Gold: <?php $current_resource['gold'] ?></td> > <td width="20%">Session id is: <?php echo > ''.$_SESSION['user_id'].'' > ?></td> > </tr> > </table> > > The error may not necessarily be to do with the session, but non of > the > $current_resources are showing. > > Thanks for any help guys/gals. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php