我有这个完全相同的代码在另一台服务器上运行良好:
$mysqli_Cxn = new mysqli($SQL_HOST,$SQL_USER,$SQL_PASS,$SQL_DB);
if($mysqli_Cxn->connect_errno){
echo 'Unable to connect!!';
exit();
}
$userID=12345;
$userFirstName = 'Charley';
$userLocale = 'en_US';
$sql = "UPDATE userProfile SET userFirstName=?, userLocale=? WHERE id=?";
if($stmt = $mysqli_Cxn->prepare($sql)){
if(!$stmt->bind_param('ssi',$userFirstName,$userLocale,$userID)){
echo "<br/><br/>Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}
if($stmt->execute()){
totalAffected=$stmt->affected_rows;
if($totalAffected>=1){
echo '<br/><br/>UPDATE OK: Affected rows = '. $totalAffected;
}
}else{
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
}
$stmt->close();
该代码给了我以下输出:执行失败:(1210)mysql_stmt_execute 的参数不正确
如果我改变这两行:
$sql = "UPDATE userProfile SET userFirstName=?, userLocale=? WHERE id=?";
$stmt->bind_param('ssi',$userFirstName,$userLocale,$userID);
对此:
$sql = "UPDATE userProfile SET userFirstName=?, userLocale='en_US' WHERE id=12345";
$stmt->bind_param('s',$userFirstName);
...然后更新成功,我没有收到任何错误。
有谁知道为什么我不能在这段代码中绑定多个参数?
我让这段代码在 Centos 4.9、PHP 5.3.3、MySQL 5.0.91/5.0.91-community-log 上完美运行
我需要在我当前的服务器 Centos 6.2、PHP 5.3.10、MySQL 5.0.95-community-log 上运行它