Re: An annoying session problem

From: Date: Mon, 19 Jun 2006 16:31:17 +0000
Subject: Re: An annoying session problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-238302@lists.php.net to get a copy of this message
Alex Major wrote:
Thanks for pointing that out, however I've changed the code to: <?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 echo $_SESSION['username'] ?></td>
</tr> <tr>
    <td width="20%">Food: <?php echo $current_resource['food'] ?></td>
    <td width="20%">Wood: <?php echo $current_resource['wood'] ?></td>
    <td width="20%">Stone: <?php echo $current_resource['stone'] ?></td>
    <td width="20%">Gold: <?php echo $current_resource['gold'] ?></td>
    <td width="20%">Session user_id is: <?php echo $_SESSION['user_id']
?></td> </tr> </table> And I'm still not getting the output correctly. I don't think that the SELECT query is working properly, is there problem with how I've put:
        WHERE user_id = '".$_SESSION['user_id']."'
  
1. Check $current_resource_result for equivalence (===) to false and print mysql_error() if it is. That will tell you if the SQL query failed and why. 2. You may also want to print $current_resource_query to confirm that the session variable actually exists. 3. There is no 3, but there certainly is a spoon. -Stut

« previous php.general (#238302) next »