Jump to content


Photo

Session Problem


  • Please log in to reply
2 replies to this topic

#1 NME

NME
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 21 May 2006 - 12:05 AM

This is my code:

$query= "SELECT userid, first_name FROM users2 WHERE username='$username' AND password='$password'";
$result = @mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_NUM); //returns the row with that users information in the users2 table.

if($row)
    {
        $_SESSION['userid']=$row[0];
        $_SESSION['first_name']=$row[1];
        $_SESSION['last_name']=$row[2];

for some reason $row[2] returns nothing (meaning $_SESSION['last_name'] is nothing as well), although $row[1] and $row[0] return the values they intend from my SQL table. why won't row[3] or any subsequent rows show?

thanks.


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 21 May 2006 - 12:13 AM

You only selected two items from the table - those will be the zeroth and first elements of the $row array.
Legend has it that reading the manual never killed anyone.
My site

#3 NME

NME
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 21 May 2006 - 12:15 AM

ah ofcourse, im an idiot. thanks so much.

should've been SELECT * FROM ...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users