0
我學習用準備好的發言中我的數據庫,以從表中選擇我的所有數據。但是我得到這個錯誤PHP編寫的語句錯誤:警告:mysqli_stmt :: bind_param():
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match
number of parameters in prepared statement in
/Applications/XAMPP/xamppfiles/htdocs/contenteditable/classes/class.Insert.inc on
line 13
也許我沒有以正確的方式使用準備好的陳述,我不確定,我已經使用過預先準備好的陳述,所以希望有人能告訴我我哪裏會出錯或者有沒有一個有用的工作示例。
這是我的代碼:
的index.php
<div id="maincontent" contenteditable="true">
<?php
//get data from database.
require("classes/class.Insert.inc");
$insert = new Insert();
$insert->read();
?>
<button id="save">Save</button>
<input type="button" id="clear" value="Clear changes" />
</div>
類/ class.Insert.php
<?php
include("connect/class.Database.inc");
class Insert extends Database {
public $firstname;
public $content;
public function read(){
$stmt = $this->mysqli->prepare('SELECT * FROM datadump');
$stmt->bind_param('s', $content);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo $content; }
}
}
?>
當我將此更改爲'bind_result'時,出現以下錯誤:致命錯誤:無法通過/Applications/XAMPP/xamppfiles/htdocs/contenteditable/classes/class.Insert.inc中的引用傳遞參數1, Jon – 001221
@gutigrewal:您是否閱讀過'bind_result'手冊?它沒有采用「s」參數,因爲這沒有任何意義(數據庫已經知道列的數據類型)。用一個功能的名稱代替另一個功能的名稱並不會奇蹟般地使事情發揮作用,這並不奇怪。 – Jon
'警告:mysqli_stmt :: bind_result():綁定變量的數量與第15行中的/Applications/XAMPP/xamppfiles/htdocs/contenteditable/classes/class.Insert.inc中的預準備語句中的字段數目不匹配當我拿出's'時出現這個錯誤@jon – 001221