我有一个mysql查询,但我无法为它绑定param
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():类型中的元素数 定义字符串与绑定变量数不匹配
答案 0 :(得分:28)
这是mysqli
$SQL = "SELECT
users.email,
users.handle,
userprofile.mobile
FROM users,userprofile
WHERE users.email =? OR users.handle =? OR userprofile.mobile=?";
if ($stmt = $mysqli->prepare($SQL)) {
$stmt->bind_param("sss", $one,$two,$three);
$stmt->execute();
//do stuff
}
答案 1 :(得分:3)
试试这个......
$stmt = $dbConn->prepare("SELECT users.email,users.handle,userprofile.mobile FROM users,userprofile WHERE users.email = ? OR users.handle = ? OR userprofile.mobile= ?");
$stmt->bind_param("sss", $email, $handle, $mobile);
$stmt->execute();