Minor MySQL Issue
Posted: Mon Aug 08, 2005 6:57 am
I've got a function with the following code:
I'm getting the following error on Line 45, and I don't know what is the problem:
Code: Select all
function login($user, $pass)
{
// connect
$conn = db_connect();
if (!$conn)
return false;
// search for the user, ** note the 'select user_id' **
$result = mysql_query("select id from user
where user = '$user'
and pass = MD5('$pass')");
// found a user?
if (!result)
{
return false;
}
if (mysql_num_rows($result)>0)
{
// store the user id
$_SESSION['user_id'] = mysql_result($conn, 0, 'user_id');
return true;
}
else
{
return false;
}
}This is line 45:Warning: mysql_result(): supplied resource is not a valid MySQL result resource in /home/virtual/site117/fst/var/www/html/portfolio/telereport/includes/global.php on line 45
Code: Select all
$_SESSION['user_id'] = mysql_result($conn, 0, 'user_id');