Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
When typing in a username and password im getting the error
mysql_num_rows(): supplied argument is not a valid MySQL result resource
IT IS SAYING I HAVE NO DATABASE SELECTED ...
I was wondering what this error means. Could it be a problem connecting to the database or is it a syntax problem. here is the code for the username and password
$query = mysql_query("SELECT * FROM Users WHERE username = '$user'");
$numrows = mysql_num_rows($query);
if($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$dbuser = $row['username'];
$dbpass = $row['password'];
$dbactive = $row['active'];
if($password == $dbpass){
if($dbactive == 1){
//set session info
$_SESSION['userid'] = $dbid;
$_SESSION['username'] = $dbuser;
echo "You have been logged in as <b>$dbuser</b> Click here to go to member page.";
}else
echo "You must activate your account to login.";
}else
echo "You did not enter the correct password.";
}else
echo "The username you entered was not found.";
}
}else
echo "You must enter your username.";
}
The problem is in the $query line. the first line