-3
即使我計算了所有參數並且相等,我仍面臨錯誤:mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
。Php函數,錯誤:變量數量與預編譯語句中的參數數目不匹配
我要求選擇查詢功能:
public function User_depodit ($Phone_number) {
$stmt = $this->conn->prepare("SELECT a.Idcustomer_info as idInfocustomer, a.Amount as currentamountCustInfo, b.Idcustomer_info as idInfocustomer2, b.IDcustomer , c.IDbank AS DepositIDbank, c.Amount as currentAmountDpsit, c.IDcustomer as IDcustomerDepodit,bnk.IDbank as bankIDbank, d.Card_Id as CardID_cardType , d.CardName , e.Amount as VisaAmount, e.Card_number as visaCardNumber, e.Exp_date as VisaExpDate,e.Security_code as visaSecurityCod, e.Card_Id AS visaCardId from customer_info a join customer b on a.Idcustomer_info = b.Idcustomer_info join deposit c on b.IDcustomer =c.IDcustomer join bank bnk on c.IDbank = bnk.IDbank join cardtype d on bnk.Card_Id= d.Card_Id join visa_info e on d.Card_Id = e.Card_Id where a.Phone_number ='?' ORDER BY a.Created_at DESC ,c.Created_at DESC ,e.Created_at DESC limit 1");
$stmt->bind_param("iiiiiiiiiiiiiii", $idInfocustomer, $currentamountCustInfo, $idInfocustomer2, $IDcustomer, $DepositIDbank, $currentAmountDpsit, $IDcustomerDepodit, $bankIDbank, $CardID_cardType, $CardName, $VisaAmount, $visaCardNumber, $VisaExpDate, $visaSecurityCod, $visaCardId);
if ($stmt->execute()) {
$user = $stmt->get_result()->fetch_assoc();
$stmt->close();
// return user's results
return $user;
}
else {
return NULL;
}
}
你的代碼失敗了你幾原因; 1)'哪裏a.Phone_number ='?''<報價。 2)沒有足夠的佔位符來支持'iiiiiiiiiiiiiii''s –
您應該回到準備好的聲明中的「官方」手冊;它都在那裏。 http://php.net/manual/en/mysqli.prepare.php –
'User_depodit'表示另一個錯字。你應該把這個數字看作'User_deposit' –