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条)

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services