编辑:感谢大家的帮助(尤其是@Marty McVry)。我刚刚编辑了这个问题。
表:购买
purchase_id | seller | buyer
12 | 2 | 5
29 | 5 | 2
$check=query("SELECT (COUNT(*) >= 2) AS RESULT
FROM purchase a
INNER JOIN purchase b
ON a.seller = b.buyer AND
a.buyer = b.seller
WHERE (a.seller = 2 AND a.buyer = 5) OR
(a.seller = 5 AND a.buyer = 2)");
$row = mysql_fetch_row($check);
echo $row[0];
if ($row[0] > 0) {
foo
} else {
bar
}
当我运行此查询时,我收到以下错误:
Warning: mysql_fetch_row() expects parameter 1 to be resource, string given in line 180
(即$row = mysql_fetch_row($check);
)。
这是怎么回事?
FIY,在这里,query()
连接到数据库并执行 SQL 语句,可能带有参数。