This is the warning Im getting:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/snissa4/public_html/test.php on line 10
<?php
if(isset($_POST['user']))
{
//variable declaration
$user = $_POST['user'];
$pass = $_POST['pass'];
//connect to data base
$con=mysqli_connect("engr-cpanel-mysql.engr.illinois.edu","socialdrinkers_b","testing123","socialdrinkers_db");
if (mysqli_num_rows(mysqli_query($con, "Select * from Drinkers where userID = '$user' AND password = '$pass'")))
{ // correct info
$result = mysqli_query("SELECT * FROM Drinkers where userID = '$user' AND password = '$pass'");
while($row = mysqli_fetch_array($result));
{//cookie implementation
$expire = time() + 60*60*24; //1 day
setcookie('idNum', $row['idNum'], $expire);
echo "Logged in as <b>".$row['userID']."</b>";
}
}
else
{ // wrong info
echo "<b>wrong id or pass</b>";
}
}
echo "<form method = 'post'>
Username: <input type = 'text' name = 'user'>
Password: <input type = 'password' name = 'pass'>
<input type = 'submit' value = 'LOG IN'>
</form>";
?>
I am not sure why I am getting this warning, and when i try to login with the username and password i made in my database, it just keeps redirecting me to this page instead of giving the success message. I cannot find out why.
Thank you for your help, struggling with my cs411 (databases) class lol