<?php?
$mysqli?=?new?MySQLi("localhost","root","root","sziitjx");
if(!$mysqli){
?die($mysqli->error);
}
//創建一個預定義的對象??占位
//?$sql?=?"select?state?from?servicer?where?servicer_id=??and?password=?";
$sql?=?"call?login(?,?)";
$mysqli_stmt?=?$mysqli->prepare($sql);
$id='1501090103';
$pw='123456';
//綁定參數
$mysqli_stmt->bind_param("ss",$id,$pw);
//綁定結果集
?$mysqli_stmt->bind_result($state);
//執行
$mysqli_stmt->execute();
//取出綁定的結果集
while($mysqli_stmt->fetch()){
?echo?"--$state--<hr>";
}
//關閉結果集
$mysqli_stmt->free_result();
$mysqli_stmt->close();
$mysqli->close();
?>$sql?=?"select?state?from?servicer?where?servicer_id=??and?password=?";執行上面這句返回的結果為1$sql?=?"call?login(?,?)";執行這句卻出錯Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement?select?state?from?servicer?where?servicer_id=user_id?and?password=pw;存儲過程是上面這句,附帶兩個參數IN?`user_id`?char(20),IN?`pw`?char(20)
PHP調用存儲過程出錯,普通SQL語句返回的結果卻正常
和你一起閃耀到世界盡頭
2016-08-28 11:24:09