2013-03-02 99 views
1
​​

我一直在嘗試解決這個問題已經有一段時間了。任何人都可以看到問題嗎?我非常懷疑$ db是問題,因爲我登錄了需要訪問$ db來創建會話。我也有一個mysqli_connect_error();在此代碼之前。MySQLi準備錯誤

$per_prep = mysqli_prepare($db, 'select Permissions from Chatpermissions where Uid = ? and Chatid = ?'); 

mysqli_stmt_bind_param($per_prep, 'ii', $uid, $chatroomid); 
mysqli_stmt_execute($per_prep); 

mysqli_stmt_bind_result($per_prep, $permission); 
mysqli_stmt_error($perprep); 
mysqli_stmt_fetch($permission); 

mysqli_stmt_close($room_prep); 

我在工作臺中測試了這個查詢,並且它調出了一個結果。

+0

固定它。 Fetch有錯誤的變量〜_〜Off爲我睡覺 – Rujikin 2013-03-02 05:47:13

回答

0

當您將stmt分配給$ per_prep時,應該使用相同的變量名稱而不是$ perprep。

$per_prep = mysqli_prepare(...); 
. . . 
mysqli_stmt_error($perprep); // wrong variable name here 

另外,fetch函數接受語句的參數,而不是您試圖將結果綁定到結果的變量。

mysqli_stmt_fetch($permission); 

應該是:

mysqli_stmt_fetch($per_prep); 
0

變化

mysqli_stmt_error($perprep); 
mysqli_stmt_fetch($permission); 

mysqli_stmt_error($per_prep); 
mysqli_stmt_fetch($per_prep);