問題描述
$stmt = $mysqli->prepare('select Un from member where Lock = ? and Activated = ?');
$stmt -> bind_param("ss", 'N', 'Y');//This line gave the error
$stmt -> execute();
$stmt->store_result();//apply to prepare statement
$numRows = $stmt->num_rows;
if ($numRows > 0)//if have result
while ($row = $stmt->fetch())
我上面的代碼給了我一個在非對象上調用成員函數 bind_param()" 錯誤.我真的不明白為什么我會收到這個錯誤.我有正確的列名.
my above code gave me a "Call to a member function bind_param() on a non-object" error. I really don't get it why i getting this error. I have correct cols name.
我是 mysqli 的新手,想學習如何調試此類錯誤.
I am new to mysqli and would like to learn how to debug such error.
- 我的準備語句或 bind_param() 有什么問題?
- 請教我如何調試此類錯誤
推薦答案
在非對象上調用成員函數 bind_param()
意味著 $stmt
,即你試圖調用 bind_param
on,不是一個對象.為什么它不是一個對象?因為 $mysqli->prepare
沒有返回一個對象.為什么它沒有返回一個對象?
Call to a member function bind_param() on a non-object
means that $stmt
, which you're trying to call bind_param
on, is not an object. Why is it not an object? Because $mysqli->prepare
did not return an object. Why did it not return an object?
mysqli_prepare()
返回一個語句對象或 FALSE
.
http://www.php.net/manual/en/mysqli.prepare.php
mysqli_prepare()
returns a statement object orFALSE
if an error occurred.
http://www.php.net/manual/en/mysqli.prepare.php
所以這意味著一定發生了錯誤.你應該打開error_reporting
,它可能會告訴你,或者檢查$mysqli->error()
,這也可能告訴你.
So that means an error must have occurred. You should turn on error_reporting
, which will probably tell you, or examine $mysqli->error()
, which may tell you as well.
這篇關于調用非對象上的成員函數 bind_param()(盡管經過研究仍無法解決)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!