Jump to content


Photo

PHP grabbing info from database problem


  • Please log in to reply
2 replies to this topic

#1 fix3r

fix3r
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 22 October 2006 - 07:39 PM

On the top of my page it shows the stats of players if they are logged in..for example, money used..attacks..unread messages..ect. Or if they aren't logged in, it telle them that they need to log in.

When someone logs in, it redirects them to the menu page where it also gives them a little info about the person.

Now here is where the problem is, when they log in and it redirects you to the page, neither top where it shwos the player's stats or the menu tells them how much of "whatever" they have. It says they have 0. But once you refersh it tells them an exact ammount of what they have.

I'm going to show you some of my code but if anyone needs anymore to figure out what the problem would be please tell me.

Config:
$result = mysql_query("SELECT * FROM users WHERE username='" . decrypt($_SESSION['login']) . "'");
$rs = mysql_fetch_array($result);

Part of index where info is displayed:
echo'<td width="15%">Money:&nbsp;<b>$' . number_format($rs['moneyout']) . '</b></td>';
echo'<td width="15%">Power:&nbsp;<b>' . number_format($rs['power']) . '</b></td>';
echo'<td width="15%">Attacks:&nbsp;<b>' . number_format($rs['attacks']) . '</b></td>';

I apprecate your help, thank you.

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 22 October 2006 - 07:57 PM

Sounds like the session isn't set on the first pageview (is accessible as $_SESSION)

#3 fix3r

fix3r
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 22 October 2006 - 07:59 PM

Sounds like the session isn't set on the first pageview (is accessible as $_SESSION)


How do I make the session set on the first page view. In the index page I have started the session but I haven't started the session on the menu page because the menu page is included in the index.

<?php
session_start();
include "config.php";
ob_start();
login_check();
?>

Thanks for your help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users