本文介紹了PHP 和 MySQLi - 無法通過引用傳遞參數 2的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在嘗試創建一個函數來檢查更新并插入一些數據,但我在第一步中遇到了一個問題,其中 $stmt->bind_param 表示不是通過引用或類似方式傳遞參數.
I am trying to make a function which will check update and insert some data but I am having an issue in the first step where the $stmt->bind_param is saying that is not passing parameters by reference or something like that.
我在下面附上了功能代碼:
I have attached below the function code:
public function killTarget($killerid,$victimiid,$victimcode)
{
if ($this->checkUsercode($victimcode,$victimiid))
{
$stmt = $this->_db->prepare("UPDATE users SET status =? WHERE user_id =?");
$stmt->bind_param("ii",0,$victimiid);
if ($stmt->execute())
{
$stmt->store_result();
$stmt->fetch();
$stmt = $this->_db->prepare("SELECT victim_id FROM target WHERE killer_id = ?");
$stmt->bind_param("i",$victimiid);
if ($stmt->execute())
{
$stmt->store_result();
$stmt->bind_result($targetid);
$stmt->fetch();
$stmt = $this->_db->prepare("INSERT INTO target (killer_id, victim_id) VALUES (?,?)");
$stmt->bind_param("ii",$killerid,$targetid);
if ($stmt->execute())
{
$stmt->store_result();
$stmt->fetch();
$stmt->close();
}
}
}
else
{
Main::setMessage("targets.php",$this->_db->error,"alert-error");
}
}
}
推薦答案
你不能在mysqli中這樣做:
You cannot do this in mysqli:
$stmt->bind_param("ii",0,$victimiid);
0
需要是一個變量.
試試這個:
$zero = 0;
$stmt->bind_param("ii",$zero,$victimiid);
這篇關于PHP 和 MySQLi - 無法通過引用傳遞參數 2的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!