I register fname like this...
session_register('fname'); $_SESSION['fname'] = $fname;
I am using print_r($_SESSION) at the top of pages to keep an eye on things...
and after I log in I can see that fname is registered...
PROBLEM: If I am selecting a list of users to modify (from the same users table),
The select statement is pretty strait forward...
$sql = "SELECT * FROM users ";
$result = @mysql_query($sql) or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result))
{$fname = $row['fname'];
Problem is ... the simple select above is changing MY (or the person logged in) session value for fname to the last result of the select statment...
I can't see why a select is changing a registered session value...
IF I change the name of the fields to different names in the While clause (in the select statement I am good...
ex. $xfname = $row['fname']; AND it doesn't CHANGE the registered session varible for that field.
It makes no sense to me ... I DIDN'T think that a register'd session value would change...WHILE it was registered.
When I register a session value should I give it a unique name? I HAVE BEEN doing this...
I hope this is clearer...
Originally posted by sijis
i'm not really sure what you are saying, but i'm going to guess.
what i believe you are saying is that in a while loop you are putting the values in a session, probably something like this:
while($row=mysql_fetch_array($sqlStatement)){
$_SESSION['db_field']=$row['db_field'];
}
but then you notice that the session db_field only has the last entry of that loops. if so, the reason is because everytime the loop executes it overrides the previous value of that session variable. Maybe giving each session a different 'name' could solve your problem.
if you are trying to validate a user just match their data to taht of the database with your sql query (if this is what you are tyring to accomplish) like
$sql = "SELECT * FROM table WHERE username='".$POST['username']."' AND password='".$POST['password']."'
then if it matches true, put those values in a session.
Since i'm not sure what you are trying accomplish, maybe some code would be helpful. but if you are trying to put a ton of values into sessions, then you should think about doing things differently, it (maybe) would be a waste of resources. [/B]