I want to run a select statement in database, and if the result is 0, than outputs something. The problem is that when I try to run the following code it closes the connection to the page with "the page isn't working". I use the following part of code inside a php file. Where I am wrong, or what can I do to fix this?
//if input != with $password in database, output wrong password
$sql="SELECT `key` FROM `invitation_keys` WHERE id = '$password'";
$res=mysqli_query($db,$sql);
if (mysqli_num_rows($res) = 0) {
echo "Wrong password";
} else {
echo "alright";
}