I am getting this error when my login.php file loads..
‘Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource’
Heres what i have..
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows!=0)
{
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
if ($username==$dbusername&&$password==$dbpassword)
{
echo "Youre in!";
}
else
echo "Incorrect Password!";
}
else
die("That user doesnt exist!");
}
else
die("Please enter a username and a password!");
?>
You missed some curly brackets:
The server could be configured that if an error shows up, the page is left blank.
Some other tips for mySQL login: Never ever put an user input directly in a MySQL query statement! It is then very easy to hack your site by means of SQL injection.
For more details: http://www.derby-web-design-agency.co.uk/blog-post/how-to-create-a-secure-login-system-in-php-part-1/12/