我写了以下代码,当它运行时,我得到"错误:查询是空的"无论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;
任何帮助都是感激的。谢谢。
$row_rsChecklists是结果资源,你在rsChecklists上有numrows。我建议在短块工作中使用真正简单的单词,如"row"。