我正在使用PHP PDO插入到使用PHP的MYSQL數據庫中。我得到的錯誤:致命錯誤:使用PHP和MYSQL時無法通過引用傳遞參數2
Fatal error: Cannot pass parameter 2 by reference in /home/sandyit/public_html/hosting/findibuzz/design2/sign-up.php on line 200
這是我的代碼:
$ ID是一個自動遞增的整數,而其餘的varchar變量如下填寫爲例:
$db = new PDO('mysql:host=localhost;dbname=dbname;charset=utf8', 'dbusername', 'dbpass');
$FULLNAME = "David";
$PW_HASH = "sadsad";
$SALT = "adadad";
$EMAIL_ADDRESS = "[email protected]";
$ID=0;
$addrequest = $db->prepare("INSERT INTO FB_USERS (ID,FULL_NAME,PASSWORD,PASSWORD_SALT,EMAIL_ADDRESS) VALUES (:ID,:FULL_NAME,:PASSWORD,:PASSWORD_SALT,:EMAIL_ADDRESS)");
$addrequest->bindParam(':ID',$ID, PDO::PARAM_INT);
$addrequest->bindParam(':FULL_NAME',$FULL_NAME, PDO::PARAM_STR);
$addrequest->bindParam(':PASSWORD',$PW_HASH, PDO::PARAM_STR);
$addrequest->bindParam(':PASSWORD_SALT',$SALT, PDO::PARAM_STR);
$addrequest->bindParam(':EMAIL_ADDRESS',$EMAIL_ADDRESS, PDO::PARAM_STR);
$addrequest->execute();
$addrequest->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
我知道我有什麼問題,但是我不能發現錯誤,請問我有什麼建議嗎?
感謝
在連接打開後立即添加'$ db-> setAttribute(PDO :: ATTR_ERRMODE,PDO :: ERRMODE_EXCEPTION);'。 –
[PHP錯誤:「無法通過引用傳遞參數2」的可能重複](https://stackoverflow.com/questions/13105373/php-error-cannot-pass-parameter-2-by-reference) –