PDA

Click to See Complete Forum and Search --> : Variable Issue


lintz
Feb 17th, 2005, 08:10 PM
Once a user logs in I create a global array variable to store all their info using the below.

$UserDetails = mysql_fetch_row($sSQL);
$GLOBALS['UserDetails'] = $UserDetails;
echo "Hello $UserDetails[0]"; //This displays the users name


The problem is when I use the below on another php page the variable is empty. I must be doing something that is simply to correct but I can't find it :confused:

global $UserDetails;
echo "Welcome $UserDetails[0]...."; //All that is displayed is Welcome ....

visualAd
Feb 18th, 2005, 02:28 AM
Global variables are not persistant accress different PHP scripts. If you want this then you will need to use sessions.

http://www.php.net/session

There is also a link in my signature to a class which allows you to save the session in a MySql database.