2012-07-21 57 views
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 
} 

爲什麼這不起作用?這讓我瘋狂。在PHP中使用mySQL_num_rows時遇到困難

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

所有的拼寫,語法,句法,而且情況是正確的。網址正在通過$i_id變量。它正確地回顯出來。

我在做什麼錯?

回答

2

有一個在condition..try這個..

if(mysql_num_rows($result) == 1) 

你逝去的$result == 1結果mysql_num_rows一個錯字其預計mysql_query()結果種源.. :)

+0

哇,謝謝你的收穫! – fyz 2012-07-21 18:16:12

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 
}   { 

試試這個