PHP Sessions
Posted: Sun May 25, 2008 11:34 am
Hey Everyone,
Im having trouble with my sessions - at least thats what I think -
. I have
<?php session_start(); ?> at the top of my page...
Then Im using <?php echo $_SESSION['first_name'];?> to show the user's first name on the page and it works good.
Now Im trying to use, <?php echo $_SESSION['location'];?>
To show the users location but its not retrieving their location. And Im wondering if anyone might know why? Im retrieving the users first_name and displaying it on the page and it works ok, how come it wont retrieve their location?
If anyone knows why this is, any help would be great. What I did to try and fix this problem is approach it a different way and just used this script where I want their location:
But the problem with using that script is it isn't just listing the location for that user, its listing all the locations from the 'location' column in the database.
Any help would be great - thanks!
Im having trouble with my sessions - at least thats what I think -
<?php session_start(); ?> at the top of my page...
Then Im using <?php echo $_SESSION['first_name'];?> to show the user's first name on the page and it works good.
Now Im trying to use, <?php echo $_SESSION['location'];?>
To show the users location but its not retrieving their location. And Im wondering if anyone might know why? Im retrieving the users first_name and displaying it on the page and it works ok, how come it wont retrieve their location?
If anyone knows why this is, any help would be great. What I did to try and fix this problem is approach it a different way and just used this script where I want their location:
Code: Select all
<?php
$con = mysql_connect("***","***","***") or die('Could not connect: ' . mysql_error());
mysql_select_db("login", $con);
$result = mysql_query("SELECT * FROM users");
while($row = mysql_fetch_array($result)){
echo "{$row['location']}";
}
?>Any help would be great - thanks!