if 语句无法识别 mysql_num_rows 返回 0 结果时
我正在尝试运行代码,但似乎给了我错误的结果,我尝试了很多方法但仍然没有得到它。这里是:
//compares vid num to db been result
$id = mysql_real_escape_string(@$_GET['g']);
$vid = mysql_real_escape_string(@$_GET['v']);
$sql= mysql_query("SELECT videos.* FROM videos WHERE videos.email =
(SELECT email FROM page WHERE page.user_id = '$id')
AND videos.videoid = '$vid'");
if (mysql_num_rows($sql) == 0) { echo "none";} else echo "it exists";
如果我在 phpmyadmin 中运行查询,它会正确运行,但是在 PHP 中运行时,结果是 offffff,即使 phpmyadmin 返回正确的 0,它也会不断回显它的存在。我一直试图弄清楚这一点,但一无所获。我尝试过相反的方法。
I am trying to run the code and it seems to be given me wrong result, I tried many ways and still not getting it. Here it is:
//compares vid num to db been result
$id = mysql_real_escape_string(@$_GET['g']);
$vid = mysql_real_escape_string(@$_GET['v']);
$sql= mysql_query("SELECT videos.* FROM videos WHERE videos.email =
(SELECT email FROM page WHERE page.user_id = '$id')
AND videos.videoid = '$vid'");
if (mysql_num_rows($sql) == 0) { echo "none";} else echo "it exists";
If I run the query in phpmyadmin it runs correct, but when run in PHP the result is offfff, it keeps echoing it exists even when phpmyadmin returns 0 which is correct. I have been trying to figure this out and keeps getting nothing. I have tried !isset($sql)
oppositely the something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果上面的代码仍然给您带来问题,那么您的 mysql 查询中的某些内容导致找不到结果。
If the above code still gives you a problem, then something in your mysql query is causing a result to be found.
这有效,谢谢你们的帮助
this works, thank you guys for your help