我有这个完全相同的代码在另一台服务器上工作得很好:
原文链接:https://www.f2er.com/php/139461.html$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',$userID);
到这个:
$sql = "UPDATE userProfile SET userFirstName=?,userLocale='en_US' WHERE id=12345"; $stmt->bind_param('s',$userFirstName);
…然后更新成功,我没有收到任何错误.
有人知道为什么我不能绑定多个param在这段代码?
我的代码在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