Forum Moderators: coopster

Message Too Old, No Replies

Passing of Session Variables

         

ukgimp

5:00 pm on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am having lots of problems with the following code. When I try to assign the value of SESSION['user_id'] from the database it calles the wrong value. However if I manually code the session to equalt "some text" when I view the session on another page it works fine.

session_start();
if(!$_SESSION['member']){
if($nick & $password){
$sql = mysql_query("SELECT password, user_id FROM users WHERE username = '$nick'");
if (mysql_num_rows($sql) == 0){
$error_login = true;
}else if ( mysql_result($sql,"password")!= $cryptopassword){
$error_login = true;
}else{

$user_id = mysql_result($sql,"user_id");
$_SESSION['member'] = true;
$_SESSION['user_id'] = "$user_id";
header("Location: index.php");

};
};
}else{
header("Location: index.php");

};

RonPK

5:06 pm on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you're using mysql_result() incorrectly. The syntax should be
mysql_result(result, row# [, column_name]);

in your case:
($sql, 0, "password")