【发布时间】:2016-03-30 02:27:15
【问题描述】:
我正在尝试通过 PHP 脚本对 Sqlite3 数据库执行更新,但遇到了一对我不理解的错误。
PHP 警告: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 致命错误:未捕获的错误:在 C:\UwAmp\www\save.php:17\n 中调用成员函数
bindParam()的布尔值:C:\n#0 {main}\n \UwAmp\www\save.php 第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->prepare 语句。 我试图研究这个,但我没有任何运气。感谢您提供的任何帮助。
【问题讨论】:
-
表结构如何?
-
Canvas_Saves表中相关字段为Save1、Save2、Save3、Save4。每个字段都是 TEXT 类型。