我有一个 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模板网!