本文介紹了如何將多個參數綁定到 MySQLi 查詢的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個 mysql 查詢,但我無法為其綁定參數
I have a mysql query, but I can't bind param for it
SELECT users.email,users.handle,userprofile.mobile FROM users,userprofile WHERE users.email =? OR users.handle =? OR userprofile.mobile=?
我試過下面的線
$query = "SELECT users.email,users.handle,userprofile.mobile FROM users,userprofile WHERE users.email =? OR users.handle =? OR userprofile.mobile=?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("sss",$email,$username,$mobile);
if ($stmt->execute()) {
if($stmt->num_rows){
echo '......';
}
}
但我收到了錯誤:
警告:mysqli_stmt::bind_param():類型中的元素數定義字符串與綁定變量的數量不匹配
Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables
推薦答案
這是mysqli
$SQL = "SELECT
users.email,
users.handle,
userprofile.mobile
FROM users,userprofile
WHERE users.email =? OR users.handle =? OR userprofile.mobile=?";
$stmt = $mysqli->prepare($SQL);
$stmt->bind_param("sss", $one,$two,$three);
$stmt->execute();
//do stuff
這篇關于如何將多個參數綁定到 MySQLi 查詢的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!