0
$i_id = $_GET['iiSL'];   

require_once('../include/dbc.php');    

$sql = "SELECT invite_id FROM invite_requests WHERE invite_id = '$i_id'";
$result = mysql_query($sql);
if(mysql_num_rows($result == 1))
{
echo 'GOOD ID EXISTS';
//ECHO IS JUST TO TEST  
} 
else
{
echo 'BAD ID IS NOT IN DB';
//ECHO IS JUST TO TEST
}

为什么这不起作用?它快把我逼疯了。

错误 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

所有拼写、语法、句法和大小写都是正确的。URL 正在传递$i_id变量。它的回声正确。

我究竟做错了什么?

4

2 回答 2

2

条件有错别字..试试这个..

if(mysql_num_rows($result) == 1)

您正在将 result 传递$result == 1mysql_num_rowswhich 期望结果资源为mysql_query()..:)

于 2012-07-21T18:13:33.213 回答
0

将代码更改为

$query1=mysql_query("SELECT count(invite_id) as total FROM invite_requests WHERE invite_id = '$i_id';");
$row = mysql_fetch_array($query1);
if ($row["total"]>"0")
{
echo 'GOOD ID EXISTS';
//ECHO IS JUST TO TEST  
} 
else
{
echo 'BAD ID IS NOT IN DB';
//ECHO IS JUST TO TEST
}           {

试试这个

于 2012-07-21T18:29:39.300 回答