doubingqi5829 2019-02-05 03:50
浏览 66

我的代码没有任何错误,但mysqli_num_rows给出零值

I made a login script in PHP, and the process needs to check whether data from login form is match with data in my table. I use mysqli_num_rows to do that. But it gives zero value. How can I fix this?

I have no idea but I've already tried a method with mysqli_fetch_array and the result is still same.

Edit : Table app_user has id_level, and id_level is a foreign key. Is there could be a problem in the database? But I'm not using id_level in the login process. Or it could be a xampp server error?

include "lib/conn.php";

$data = mysqli_query($conn, "SELECT * FROM app_user WHERE username='$user' AND password='$pass'") or die(mysqli_error($conn));
echo "<pre>".print_r($data, true)."</pre>";

if(mysqli_num_rows($data) == 0){
    $_SESSION['error'] = '<strong>ERROR!</strong> username atau password salah.';
    //header('Location:login.php');
    echo "x";
    die();
}

So, I want mysqli_num_rows to give me 1, but the existing output is 0.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 Arcgis相交分析无法绘制一个或多个图形
    • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
    • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格