An annoying session problem

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

 



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.

-- 
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