Hi Guys,
I have a simple mysql_num_rows() expects parameter 1 to be resource, boolean given error in my script, I have tried to debug it myself but I don't understand why the script doesn't think the variable "$query" isn't an integer. I am trying to create a login form for users who are already registered and I want them to be able to see instant feedback as to whether their info has been accepted or not. The users won't be redirected though.
testlogin.php
<?php
$name = $_GET['name'];
$password = $_GET['password'];
if (!$name && $password) {
echo "Error";
exit;
}
mysql_connect("localhost" , "root" , "") or die("Issue with connection!");
mysql_select_db("testlogin");
$query = mysql_query("SELECT * FROM users WHERE Name='".$name."'");
$name = $_GET['name'];
$password = $_GET['password'];
if(!$name && $password) {
echo 'No name or password';
exit();
}
mysql_connect("localhost","root", "");
mysql_select_db("testlogin");
$query = mysql_query("SELECT * FROM users WHERE Name ='".$name."'");
$numrows = mysql_num_rows($query);
if($numrows !=0) {
while($row = mysql_fetch_assoc($query)) {
$dbname = $row['Username'];
$dbpassword = $row['password'];
}
if($name == $dbname && $password == $dbpassword) {
echo "you are in!";
}else {
echo "Please enter a valid username and password";
}
}else {
echo "Your name is not registered!";
}
?>