$sql="SELECT count(actid) AS tr
FROM useractions ua
WHERE qid=-1
OR qid IN (
SELECT qid
FROM questions q
WHERE q.visible=".VISIBLE."
)
AND ua.actid =".$actid;
上面的查询给出了这个错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
这句话有什么问题吗?
我做了一个转储并得到了这个:
string "SELECT count(actid) AS tr FROM useractions ua WHERE qid=-1 OR qid IN ( SELECT qid FROM questions q WHERE q.visible=1 ) AND ua.actid =" (length=270)
$actid
是另一个查询的结果,如下所示。然后将其传递给上面显示查询的函数。
foreach ($_POST['q'] as $qid) {
list($actid) = mysql_fetch_row(mysql_query("SELECT actid FROM useractions WHERE qid='$qid'"));
upd_facts_status($actid);
}
最佳答案
验证 VISIBLE
常量是否具有值以及 $actid
变量是否具有值。
关于php - SQL查询错误,无法判断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8334643/