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;
}
}
I'm getting the following error on Line 45, and I don't know what is the problem:
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
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
function get_area() {
$conn = db_connect();
if (!$conn)
return false;
mysql_query("SELECT * FROM `user` WHERE `id` = " . (int)$_SESSION['id'] . " AND `area` = '$area' LIMIT 25");
// added a $ before result here
if (!$result)
return false;
if (mysql_num_rows($result)>0)
return true;
else
return false;
// here's a line to extract the row from the db
$array = mysql_fetch_assoc($result);
// store the area in $area
$area = $array['area'];
}
When I try the following code it doesn't output anything.