为了账号安全,请及时绑定邮箱和手机立即绑定

错误:警告:mysql_num_rows()期望参数1为资源,在第19行的C:\ xampp

错误:警告:mysql_num_rows()期望参数1为资源,在第19行的C:\ xampp

PHP
慕妹3242003 2019-11-04 13:04:54
我不断收到使用的错误消息mysql_num_rows(),您能帮我弄清楚我的代码出了什么问题吗?这是我的代码:<?php //check if the user press submitif (isset($_POST['submit'] )) {    $customer = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]); // filter everything but numbers and letters    $password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]); // filter everything but numbers and letters    $sql = mysql_query("SELECT id FROM members WHERE username='$customer' AND password='$password' LIMIT 1"); // query the person    // ------- MAKE SURE PERSON EXISTS IN DATABASE ---------    $existCount = mysql_num_rows($sql); // count the row nums    if ($existCount == 1) { // evaluate the count         while($row = mysql_fetch_array($sql)){              $id = $row["id"];         }         $_SESSION["id"] = $id;         $_SESSION["customer"] = $customer;         $_SESSION["password"] = $password;         header("location: index.php");         exit();    } else {        echo 'That information is incorrect, try again <a href="customer_login.php">Click Here</a>';        exit();    }}?>我已经mysql_errno()按照您的建议尝试了..它回显1146当我搜索该错误时说1146: Table 'kossu.nonexistenttable' doesn't exist但是我不知道这意味着什么...请帮助。
查看完整描述

3 回答

?
元芳怎么了

TA贡献1798条经验 获得超7个赞

可能mysql_query()失败了。在这种情况下,它返回false。使用mysql_error()找出会发生什么。


查看完整回答
反对 回复 2019-11-04
?
倚天杖

TA贡献1828条经验 获得超3个赞

我真的不知道,我还要说些什么。该表kossu.nonexistenttable不存在。我认为,这确实很明显,这意味着什么。在您的情况下,似乎没有members要查询的表。另外我mysql_error()没有说mysql_errno()。对于第一个,您将收到具体的错误消息,而不是不确定的错误代码。这比您从PHP手册中获得的示例输出要有用一些;)

查看完整回答
反对 回复 2019-11-04
  • 3 回答
  • 0 关注
  • 477 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信