PHP LoginScript MySQL检查结果错误[重复]

时间:2021-11-06 06:33:40

This question already has an answer here:

这个问题在这里已有答案:

I just started PHP linked to MySQL and I got a really annoying problem. The complete warning on my server says:

我刚刚启动PHP链接到MySQL,我遇到了一个非常烦人的问题。我服务器上的完整警告说:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in DIRECTION REMOVED BY ME on line 20 Wrong Username or Password

警告:mysql_num_rows()期望参数1是资源,在第20行的DIRECTION REMOVED BY ME中给出的布尔值错误的用户名或密码

I am pretty sure the Password or Username is not wrong, it's just the If/else which will give this as a result. So here is the php file which will be called when pressing the login button.

我很确定密码或用户名没有错,只是If / else会给出结果。所以这里是按下登录按钮时将调用的php文件。

CODE HERE: http://pastie.org/private/tqubwhlha0wcyiotkgzeyg

代码在这里:http://pastie.org/private/tqubwhlha0wcyiotkgzeyg

So why does this happen?

那么为什么会这样呢?

1 个解决方案

#1


0  

$myusername=mysql_real_escape_string($_POST['email']);
$mypassword=mysql_real_escape_string($_POST['password']);

$sql="SELECT * FROM $users WHERE email='$email' and password='$password'";
$result=mysql_query($sql);

you probably want $mypassword isntead of $password and instead of $email (which is not even set) you have it as $myusername

你可能想要$ mypassword而不是$ password而不是$ email(甚至没有设置)你把它作为$ myusername

The functions you are using are deprecated, have a look at this. Also, (heads up) you really shouldn´t store the password (even less if it´s plain text!!) in the session, have a look.

您正在使用的功能已弃用,请查看此内容。另外,(抬头)你真的不应该在会话中存储密码(如果是纯文本!!),请看看。

#1


0  

$myusername=mysql_real_escape_string($_POST['email']);
$mypassword=mysql_real_escape_string($_POST['password']);

$sql="SELECT * FROM $users WHERE email='$email' and password='$password'";
$result=mysql_query($sql);

you probably want $mypassword isntead of $password and instead of $email (which is not even set) you have it as $myusername

你可能想要$ mypassword而不是$ password而不是$ email(甚至没有设置)你把它作为$ myusername

The functions you are using are deprecated, have a look at this. Also, (heads up) you really shouldn´t store the password (even less if it´s plain text!!) in the session, have a look.

您正在使用的功能已弃用,请查看此内容。另外,(抬头)你真的不应该在会话中存储密码(如果是纯文本!!),请看看。