Php函数,错误:变量数与准备语句中的参数数不匹配

Php函数,错误:变量数与准备语句中的参数数不匹配,php,mysql,Php,Mysql,我面临一个错误:mysqli_stmt::bind_param:变量的数量与prepared语句中的参数数量不匹配,即使我计算了所有参数并相等 我为select查询调用的函数: 我被错误地绑定了错误的参数,我最终修复了它,如下所示: public function UserDepodit ($Phone_number) { $stmt = $this->conn->prepare("SELECT a.Idcustomer_inf

我面临一个错误:mysqli_stmt::bind_param:变量的数量与prepared语句中的参数数量不匹配,即使我计算了所有参数并相等

我为select查询调用的函数:


我被错误地绑定了错误的参数,我最终修复了它,如下所示:

 public function UserDepodit ($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("i", $Phone_number);


    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没有足够的占位符来支持IIIII的声明,您应该回到关于准备好的声明的官方手册;都在里面。用户_depodit将成为另一个打字错误。你应该读作用户存款的数字,我把a.Phone\u number=“?”改为a.Phone\u number=?”?但错误依然存在@FredFunction name似乎没有问题,因为我将它改为UserDepodit,但对@Fred没有帮助
 public function UserDepodit ($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("i", $Phone_number);


    if ($stmt->execute()) {
        $user = $stmt->get_result()->fetch_assoc();
        $stmt->close();

            // return user's results
            return $user;


        }
        else {
        return NULL;
    }
}