我不断收到错误Unknown Column in field List
。字段列表中的未知列
该数据库具有以下字段:
ID - AUTO INCRIMENT
username
password
groupID
prefs_list_item
这里是我的代码。这些变量作为一个设置值存储在上面,我知道这并不会给我任何问题,因为我在同一个脚本中的其他数据库中使用它们。
try {
$wpdb = new PDO('mysql:host=localhost; dbname=******', '*******',
'*******');
$wpdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//Creates the SQL statement to write into the picture database
$pictureUPDATE = $wpdb->prepare
("INSERT INTO pe_users (
username,
password,
groupID
) VALUES (
$username,
$passmd5,
$groupID
)
");
//Executes the writing into the picture database
$pictureUPDATE->execute();
echo("<p>Your account to upload photos is now active!</p>");
}
//catches any errors that might have come from updating the picture databse
catch (PDOException $ex) {
$msg = $ex->errorInfo;
error_log(var_export($msg, true));
die("<p>Sorry, there was a unrecoverable database error with PICTURES.
Debug data has been logged.</p>");
}
不知道发生了什么事,任何人都有线索?
MD5是不安全的。您应该使用bcrypt或PBKDFv2。 – SLaks
你正在调用'prepare()',但你没有绑定任何变量。相反,您只需插入PHP变量'$ username,$ passmd5,$ groupID'。您没有获得准备好的声明的安全性。 (更不用说你的变量看起来不会被引用,除非它们在字符串变量中引用) –
但是你确定它是'INSERT'语句导致错误吗? –