Php IF语句有效,但ELSE语句无效';T

Php IF语句有效,但ELSE语句无效';T,php,Php,我有下面的陈述,如果ELSE不起作用?不工作,我的意思是它只是运行while循环并显示H1,而不检查结果是否为空 有人能看到明显的错误吗 if($interests_result != 0) { print "<h1>Users with the same interests!</h1><div style='clear:both;'>"; while($interests_row = mysql_fetch_array

我有下面的陈述,如果ELSE不起作用?不工作,我的意思是它只是运行while循环并显示H1,而不检查结果是否为空

有人能看到明显的错误吗

    if($interests_result != 0) {
        print "<h1>Users with the same interests!</h1><div style='clear:both;'>";
        while($interests_row = mysql_fetch_array($interests_result, MYSQL_ASSOC))
        {
            $int_user = $interests_row['user_id'];
            $int_twit_user = $interests_row['twitterUser'];

            $divLeft = '<div class="user-box" id="thediv_'.$int_user.'"><div class="twithandlepic"><img src="http://api.twitter.com/1/users/profile_image/';
            $divRight = '<div class="twithandle">';
            $clearDiv = '<div style="clear:both;"></div>';

            print $divLeft.strip_tags($int_twit_user)."?size=normal\" style=\"width:48px; height:48px;\"/><br \/>".$int_twit_user.$divRight."<a href='javascript:void(0);'   id='".$interests_row['user_id']."' class='getIntPoint'>Get ".$interests_row['coff']." <input type='hidden' value='".$interests_row['coff']."' class='credoff' name='credoff'/> credit(s)</a><br /></div>$clearDiv</div></div>"; 
        }
        print $clearDiv."</div>"; 
    }
    else
    {
        print "No users to display!";
    }

mysql\u query()
在成功时返回资源,或在出错时返回FALSE,而不是0

mysql\u query()
在成功时返回资源,或在出错时返回FALSE,而不是0

mysql\u query
返回资源或
FALSE
(如果有错误)

您似乎希望它包含返回的行数,而实际情况并非如此


用于比较。

mysql\u query
返回资源或
FALSE
(如果有错误)

您似乎希望它包含返回的行数,而实际情况并非如此


用于比较。

$interests\u result
是一个mysql资源。它不等于0,(
$interests\u result!=0
为真),所以执行
时的

您要检查的是:

if (mysql_num_rows($interests_result) != 0) {

$interests\u result
是一个mysql资源。它不等于0,(
$interests\u result!=0
为真),所以执行
时的

您要检查的是:

if (mysql_num_rows($interests_result) != 0) {

您要检查返回的行数。

您要检查返回的行数。

您给
$interests\u result
分配了什么值?我更新了我的问题昆廷…您给
$interests\u result
分配了什么值?我更新了我的问题昆廷。。。