PHP Recordset返回“错误:查询为空”

时间:2011-12-28 04:23:20

标签: php sql

我编写了以下代码,当它运行时,无论SQL查询是什么,我都会收到“错误:查询为空”。我知道生成的SQL很好,因为如果我将它粘贴到SQL数据库中它会返回行。记录集的PHP代码已经粘贴在其他工作正常的页面上,因此我无法查看错误的位置。

案例4://检查用户之前是否已加载清单

    $mySQL = "SELECT * FROM tools_userChklists WHERE chklistID = '" . $_GET['chklistID'] . "'";
            echo $mySQL;
    $query_rsChecklists = $mySQL;
    $rsChecklists = mysql_query($query_rsChecklists) or die(mysql_error());
    $row_rsChecklists = mysql_fetch_assoc($rsChecklists);
    $totalRows_rsChecklists = mysql_num_rows($rsChecklists);

    if ($totalRows_rsChecklists <> 0){
        //the user has already opened this checklist
        $_SESSION['redirectorAction'] = "";
        $_SESSION['redirectorAction'] = "Location: actions.php?action=5&chklistID=" . $_GET['chklistID'];
    }else{
        //the user has never opened this checklist
        $_SESSION['redirectorAction'] = "";
        $_SESSION['redirectorAction'] = "Location: actions.php?action=6&chklistID=" . $_GET['chklistID'];
    }
break;

感谢任何帮助。感谢。

1 个答案:

答案 0 :(得分:0)

$ row_rsChecklists是结果资源,你在rsChecklists上有数字。我建议使用像'row'这样的简单单词来进行短块工作。