這裏是我的代碼:如何在PHP中解決'無法通過引用傳遞參數'錯誤?
$stmt = $conn->mysqli->prepare('INSERT INTO photos (CaseNo, ImageName, CaptureTime, UploadTime) VALUES (?,?,?,?)');
$stmt->bind_param('isss', $caseno, $index.'.'.$extension, date('Y-m-d H:i:s'), date('Y-m-d H:i:s'));
我已經試過這也:
$stmt = $conn->mysqli->prepare('INSERT INTO photos (CaseNo, ImageName, CaptureTime, UploadTime) VALUES (?,?,?,?)');
$captureTime = date('Y-m-d H:i:s');
$uploadTime = date('Y-m-d H:i:s');
$stmt->bind_param('isss', $caseno, $index.'.'.$extension, $captureTime, $uploadTime);
我收到錯誤:
Fatal error:** Cannot pass parameter 3 by reference in **...file path...line #
請注意,CaptureTime和UploadeTime有數據類型日期。而忽略了我傳遞第三和第四參數的值相同的事實。
代碼有什麼問題?
[PHP mysqli包裝:通過引用傳遞__call()和call_user_func_array()]的可能重複(http://stackoverflow.com/questions/2566289/php-mysqli-wrapper-passing-by-reference-with- call-and-call-user-func-array) – ajreal
參考爲:此問題有類似問題 http://stackoverflow.com/questions/13105373/php-error-cannot-pass-parameter-2-通過引用 – Yoshi
[PHP錯誤:「無法通過引用傳遞參數2」](https://stackoverflow.com/questions/13105373/php-error-cannot-pass-parameter-2-by-reference) –