1

我不断收到错误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>");
                         }

不知道怎么回事,有人知道吗?

4

2 回答 2

0

实际上这groupID不是问题,围绕我的变量我需要添加'{ }'所以它看起来像这样...... $pictureUPDATE = $wpdb->prepare ("INSERT INTO pe_users ( username, password, groupID ) VALUES ( '{$username}', '{$passmd5}', '{$groupID}' ) ");

于 2012-11-29T20:15:32.633 回答
0

尝试做:

$data = array( 'username' => $username, 'password' => $passmd5, 'groupID' => $groupID );

$pictureUPDATE = $wpdb->("INSERT INTO pe_users 
          (username, password, groupID) value (:username, :password, :groupID)");

$pictureUPDATE->execute($data);
于 2012-11-29T03:43:54.600 回答