問題描述
我有這個完全相同的代碼在另一臺服務(wù)器上運(yùn)行良好:
I have this exact same code working great on another server:
$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();
該代碼給了我以下輸出:執(zhí)行失敗:(1210) mysql_stmt_execute 的參數(shù)不正確
That code gives me the following output: Execute failed: (1210) Incorrect arguments to 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);
...然后更新成功,我沒有收到任何錯誤.
...then the Update is successful and I don't get any error.
有誰知道為什么我不能在這段代碼中綁定多個參數(shù)?
我讓這段代碼在 Centos 4.9、PHP 5.3.3、MySQL 5.0.91/5.0.91-community-log 上完美運(yùn)行
I had this code running perfectly on a Centos 4.9, PHP 5.3.3, MySQL 5.0.91/5.0.91-community-log
我需要在我當(dāng)前的服務(wù)器上運(yùn)行它,它是 Centos 6.2、PHP 5.3.10、MySQL 5.0.95-community-log
I need to run it on my current server which is Centos 6.2, PHP 5.3.10, MySQL 5.0.95-community-log
推薦答案
我做了一點(diǎn)研究,結(jié)合您的 GCC 版本和您使用的優(yōu)化標(biāo)志,這似乎是 MySQL 源中報(bào)告的錯誤.如果您無法更改 MySQL 版本,請嘗試重新編譯 MySQL,并將 -fno-strict-aliasing 添加到您的 CFLAGS.
I did a little research, and it seems like a reported error in the MySQL source in combination with your version of GCC and the optimization flags you use. If you can't change the MySQL version, try recompile MySQL with added -fno-strict-aliasing to your CFLAGS.
參見 http://bugs.mysql.com/bug.php?id=48284 了解更多詳情
這篇關(guān)于mysqli bind_param 給出錯誤:(1210) mysql_stmt_execute 的參數(shù)不正確的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!