我試圖通過PHP腳本執行更新到Sqlite3數據庫,但我遇到了一對我不明白的錯誤。執行基於變量的sqlite3更新通過php
PHP Warning: SQLite3::prepare(): Unable to prepare statement: 1, no such column: :column in C:\UwAmp\www\save.php on line 16, referer: http://localhost/Canvas.html
PHP Fatal error: Uncaught Error: Call to a member function
bindParam()
on boolean in C:\UwAmp\www\save.php:17\nStack trace:\n#0 {main}\n thrown in C:\UwAmp\www\save.php on line 17, referer: http://localhost/Canvas.html
這裏是我使用的PHP代碼的例子:
$url = $_POST['newURL'];
$name = $_POST['saveName'];
$index = $_POST['saveNum'];
$user = $_POST['username'];
$db = new SQLite3('Users.db');
$statement = $db->prepare("UPDATE Canvas_Saves SET ':column' = ':url' WHERE User = ':user'");
$statement->bindParam(':url', $url);
$statement->bindParam(':user', $user);
if($index ===1){
$statement->bindParam(':column', 'Save1',SQLITE3_TEXT);
}
else if($index ===2){
$statement->bindParam(':column', 'Save2',SQLITE3_TEXT);
}
else if($index ===3){
$statement->bindParam(':column', 'Save3',SQLITE3_TEXT);
}
else if($index ===4){
$statement->bindParam(':column', 'Save4',SQLITE3_TEXT);
}
$statement->execute();
第16行是$ DB->準備發言。 我試圖研究這個,但我沒有任何運氣。感謝您提供任何幫助。
是怎樣的表結構? –
表Canvas_Saves中的相關字段爲Save1,Save2,Save3,Save4。每個字段都是TEXT類型。 – Bromic