dongmao4486 2016-10-19 09:14
浏览 692
已采纳

MySQL返回一个空的结果,仍然显示为1

I have a query which is to check data from two different tables everything is working fine though. When i paste the query in cPanel then result is showing like this MySQL returned an empty result set (i.e. zero rows). (Query took 0.0005 sec)

but when i count the query in php it is returing 1 instead of 0 don't know why Here is my Sql query

  SELECT mobile, emailid
FROM tbl_users
WHERE mobile =9653878051
AND emailid = 'rawat@gmail.com'
GROUP BY mobile
UNION ALL SELECT mobile, email
FROM tbl_addusr
WHERE mobile =9653878051
AND email = 'rawat@gmail
.com'
LIMIT 0 , 30

and i am counting it like this i am storing the sql result in data variable

     $result = mysql_num_rows($data);

  echo count($result)>0?1:0;  

and it is resulting 1 instead of 0

  • 写回答

4条回答 默认 最新

  • doutui2883 2016-10-19 09:23
    关注

    You do not need to count anything. mysql_num_rows gives you the number of rows.

    Use like this:

    $result = mysql_query($query);
    echo  mysql_num_rows($result);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀