Re: An annoying session problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux