Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\registration\login.php on line 19
is the error i get when i run the below code
i cant figure out what is wrong with it. :(

<?php

$username = $_POST ['username'];
$password = $_POST ['password'];

if ($username&&$password){
    $connect = mysql_connect("localhost","root","") or die("Couldn't connect!");
    mysql_select_db("phplogin") or die("Couldn't find db");
    

    
$query = mysql_query("SELECT * FROM users WHERE username='$username");

$numrows = mysql_num_rows($query);

echo $numrows;

    
}
else
    die("Please enter a username and password");
?>

Recommended Answers

All 3 Replies

Line 12 seems to be missing a single quote at the end of the username variable.

Thank you very much :)
Feel stupid now that i didn't notice it :P

It's no problem, it always helps to have a second par of eyes for things like that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.