简体   繁体   English

警告:mysql_num_rows():提供的参数不是没有mysql_error()的有效MySQL结果资源

[英]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource with no mysql_error()

I have spent the last hour and a half looking over this code and I cannot figure out what is wrong. 我花了最后一个半小时查看这段代码,但我无法弄清楚出了什么问题。 It does not return any errors, and the while loops called with the query work fine, but mysql_num_rows will not work. 它不返回任何错误,并且用查询调用的while循环可以正常工作,但是mysql_num_rows将不起作用。

Before I reading the code I want you to know that I have tried taking out all of that extra mess in the query, such as Order By but it still throws the warning. 在阅读代码之前,我想让您知道我已经尝试消除查询中的所有额外混乱,例如Order By但是它仍然会发出警告。

The Code: 编码:

    <?php
    global $_SESSION,$os_DB,$ui,$count;
    //Loggedin
    if($_SESSION['login']!=1)
    {
        print "You must be logged in.";
        include($root . 'footer.php');
        exit;
    }
    //Check banned account
    elseif($ui['level']=="2"){
        print "Sorry but your account is banned.";
        include($root . 'footer.php');
        exit;
    }
    //Check email verified
    elseif($ui['email_check']=="0"){
        print "Sorry but your account has not been verified, to verify your account now please visit <a href='index.php?index=verify&email=".$ui['email']."'>THIS LINK</a>.";
        include($root . 'footer.php');
        exit;
    }
    date_default_timezone_set('America/New_York');
    $country= $ui['country'];
    $dates=mysql_query("SELECT * FROM `contest` WHERE `countries` LIKE '%$country%'");
    $timestamp = time();

    $getcontests = $os_DB->query("SELECT * FROM contest WHERE date_1 <= '$timestamp' AND date_2 >= '$timestamp' AND countries LIKE '%$country%'");
        $num = $os_DB->num($getcontests);

            if($num == 0){
            print"<td colspan='4'>There are currently no active contests</td>";
            }
            else
            {

    while ($dat = mysql_fetch_array($dates)) {
    $tname = preg_replace('/\s+/', '', $dat['name']);
///////////Problem Area vvvv////////////////////////
    $places="(SELECT * FROM `".$tname."_contest` WHERE `username` <> 'admin' AND `completed` >= '".$dat['min_offers']."' ORDER BY `completed` DESC LIMIT ".$dat['rewards'].")";
    $results=mysql_query($places) or die(mysql_error());

    if ($dat['rewards'] == 1){
    $reward = "".$dat['reward_1']."";
    }
    else if ($dat['rewards'] == 2){
    $reward = "".$dat['reward_1'].",".$dat['reward_2']."";
    }
    else if ($dat['rewards'] == 3){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3']."";
    }
    else if ($dat['rewards'] == 4){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4']."";
    }
    else if ($dat['rewards'] == 5){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5']."";
    }
    else if ($dat['rewards'] == 6){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6']."";
    }
    else if ($dat['rewards'] == 7){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6'].",".$dat['reward_7']."";
    }
    else if ($dat['rewards'] == 8){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6'].",".$dat['reward_7'].",".$dat['reward_8']."";
    }
    else if ($dat['rewards'] == 9){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6'].",".$dat['reward_7'].",".$dat['reward_8'].",".$dat['reward_9']."";
    }
    else if ($dat['rewards'] == 10){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6'].",".$dat['reward_7'].",".$dat['reward_8'].",".$dat['reward_9'].",".$dat['reward_10']."";
    }

    $rewardsa = explode(",", $reward);
    $i=0;
    $a=1;

    // Offers Contest

    if(time() <= $dat['date_2'] && time() >= $dat['date_1'] && $dat['type'] == offer) {
    print" <table width ='100%'><tr><th align='center'><font size='4'>{$dat['name']}</font></th><th align='right'><font size='1'>".date("m/d/Y h:i A", $dat['date_1'])."-".date("m/d/Y h:i A", $dat['date_2'])."</font></th></tr></table><br />".$dat['desc']."<br /><font size='1' color='white'>You must complete offers worth at least ".$dat['min_points']." points or $".$dat['min_cash']." to count towards contest!<br /><br />
    You must also complete at least ".$dat['min_offers']." offers in order to be eligible for winnings.</font><br /><br />";
    print" <table width ='100%'><tr><th align='left'>Place</th><th align='center'>User</th><th align='right'>Prize</th><th align='right'>Completed</th></tr>";

    if(mysql_num_rows($results == 0)){
    if($dat['r_type'] == points){
    print"  <tr><td align='left'>{$a}</td><td align='center'>......</td><td align='right'>{$rewardsa[$i]} points</td><td align='right'>--</td></tr>";
    }
    if($dat['r_type'] == cash){
    print"  <tr><td align='left'>{$a}</td><td align='center'>......</td><td align='right'>$".$rewardsa[$i]."</td><td align='right'>--</td></tr>";
    }
    $i++;
    $a++;
    }


    while ($place = mysql_fetch_array($results)) {
    if($dat['r_type'] == points){
    print"  <tr><td align='left'>{$a}</td><td align='center'>{$place['username']}</td><td align='right'>{$rewardsa[$i]} points</td><td align='right'>{$place['completed']}</td></tr>";
    }
    if($dat['r_type'] == cash){
    print"  <tr><td align='left'>{$a}</td><td align='center'>{$place['username']}</td><td align='right'>$".$rewardsa[$i]."</td><td align='right'>{$place['completed']}</td></tr>";
    }
    $i++;
    $a++;
    }
    }
    }
    }

    ?>  
    </table>

在代码中将mysql_num_rows($results == 0)替换为mysql_num_rows($results) == 0

您应该改为使用mysql_num_rows($results) == 0

This 这个

if(mysql_num_rows($results == 0)){

Should be 应该

if(mysql_num_rows($results) == 0){

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 警告mysql_num_rows():提供的参数不是有效的MySQL结果 - Warning mysql_num_rows(): supplied argument is not a valid MySQL result mysql_num_rows():提供的参数不是有效的MySQL结果资源 - mysql_num_rows(): supplied argument is not a valid MySQL result resource mysql_num_rows():提供的参数不是有效的MySQL结果资源 - mysql_num_rows(): supplied argument is not a valid MySQL result resource 警告:mysql_num_rows():提供的参数不是有效的MySQL结果资源 - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 警告:mysql_num_rows():提供的参数不是有效的MySQL结果资源 - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 警告:mysql_num_rows():提供的参数不是有效的MySQL结果资源nationalbuilder webhooks API - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource nationbuilder webhooks API 警告:mysql_num_rows():提供的参数不是有效的 MySQL 结果资源 - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 帮助 我在使用 PHP 时收到一条错误消息“警告:mysql_num_rows():提供的参数不是有效的 MySQL 结果资源...” - Help I have an error message using PHP “Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in…” 修复错误:mysql_num_rows():提供的参数不是有效的MySQL结果资源 - Fixing the error: mysql_num_rows(): supplied argument is not a valid MySQL result resource 警告:mysql_num_rows():提供的参数无效 - Warning: mysql_num_rows(): supplied argument is not a valid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM