An annoying session problem

From: Date: Mon, 19 Jun 2006 15:26:29 +0000
Subject: An annoying session problem
Groups: php.general 
Request: Send a blank email to php-general+get-238292@lists.php.net to get a copy of this message
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']."'"; $current_resource_result = mysql_query($current_resource_query); $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.

« previous php.general (#238292) next »