doulan0297 2017-12-23 17:02
浏览 90
已采纳

mysqli_num_rows()期望参数1为mysqli_result,第12行的C:\ wamp \ www \ DbConnect.php中给出了字符串

This is my php code and whenever i runs it i get that error ...database is on localhost wamp server

<?php
$username ="root";
$password= "";
$hostname ="localhost";
$database ="mydata";
$check="";
$conn = new mysqli($hostname, $username, $password, $database);
$i = "SELECT * FROM `patient` WHERE 1";
$num_rows = mysqli_num_rows($i);
while($row = mysqli_fetch_array($i))
{
$r[]=$row;
$check=$row["emailid"];
}
if($check==NULL)
{
$r[$num_rows]="Record is not available";
print(json_encode($r));
}
else
{
$r[$num_rows]="success";
print(json_encode($r));
}
//mysql_close($conn);
?>

please suggest the solution for this.

  • 写回答

1条回答 默认 最新

  • dongmei2351 2017-12-23 17:05
    关注

    change your connection

    $conn=mysqli_connect($hostname, $username, $password, $database);
    

    you have wrong sql

    change this

    $i = "SELECT * FROM `patient` WHERE 1";
    

    to

    $i = "SELECT * FROM `patient` WHERE your_cloumn_name = 1";
    

    and you have not executed the your

    add

    $result=mysqli_query($conn,$i);
    

    and then

    while($row = mysqli_fetch_array($result))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化