php if statement closes server connection [duplicate]

问题: This question already has an answer here: The 3 different equals 5 answers I want to run a select statement in database, and if the result is 0, th...

问题:

This question already has an answer here:

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";
}

回答1:

if (mysqli_num_rows($res) = 0)

One equal sign sets it to = 0, you need == to compare.

  • 发表于 2019-03-25 19:18
  • 阅读 ( 157 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除