what's wrong with my codes??
it say's "mysql_num_rows() expects parameter 1 to be resource, boolean given"
-----------------
$log_username = $_POST['username'];
$log_password = $_POST['password'];
$sql_user_verify = "SELECT COUNT(*) FROM users WHERE username= '$log_username' AND password = '$log_password'";
$user_result = mysql_query($sql_user_verify,$conn);
if(mysql_num_rows($user_result) == 1) {
//login successfull
}
----------------
my plan is to crete login form and check it in database and verify it...
mysql_num_rows() expects parameter 1 to be resource, boolean
Moderator: General Moderators
-
roughneck86
- Forum Newbie
- Posts: 1
- Joined: Tue Dec 22, 2009 6:54 am
Re: mysql_num_rows() expects parameter 1 to be resource, boolean
The mysql_query is failing, returning false. Check your database connection.
As an extra note, never place $_POST/$_GET/$_COOKIE etc. details directly into an SQL query (because magic_quotes should be turned off).
You should use this:
As an extra note, never place $_POST/$_GET/$_COOKIE etc. details directly into an SQL query (because magic_quotes should be turned off).
You should use this:
Code: Select all
if (get_magic_quotes_gpc()) {
$_POST['username'] = stripslashes($_POST['username']);
$_POST['password'] = stripslashes($_POST['password']);
}
$log_username = mysql_real_escape_string($_POST['username']);
$log_password = mysql_real_escape_string($_POST['password']);
...