本文介紹了PHP 和 MySQLi - 無(wú)法通過(guò)引用傳遞參數(shù) 2的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我正在嘗試創(chuàng)建一個(gè)函數(shù)來(lái)檢查更新并插入一些數(shù)據(jù),但我在第一步中遇到了一個(gè)問(wèn)題,其中 $stmt->bind_param 表示不是通過(guò)引用或類(lèi)似方式傳遞參數(shù).
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
需要是一個(gè)變量.
試試這個(gè):
$zero = 0;
$stmt->bind_param("ii",$zero,$victimiid);
這篇關(guān)于PHP 和 MySQLi - 無(wú)法通過(guò)引用傳遞參數(shù) 2的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!