在PHP PDO中插入用户类型(用于tutis登录)

在PHP PDO中插入用户类型(用于tutis登录),php,mysql,database,pdo,Php,Mysql,Database,Pdo,我正在使用Tutis登录脚本 在register()函数中,我只希望能够在创建新用户时为保存在数据库中的数据再添加一个值。该脚本使用一个数据库表users,其中包含一定数量的列,我还需要一个列type,我已经将它添加到数据库中的表中 问题是我不知道为什么这段代码不起作用: $database->query('INSERT INTO users(username, password, email, date, type) VALUES (:username, :password, :ema

我正在使用Tutis登录脚本

register()
函数中,我只希望能够在创建新用户时为保存在数据库中的数据再添加一个值。该脚本使用一个数据库表
users
,其中包含一定数量的列,我还需要一个列
type
,我已经将它添加到数据库中的表中

问题是我不知道为什么这段代码不起作用:

$database->query('INSERT INTO users(username, password, email, date, type) 
VALUES (:username, :password, :email, :date, :type)', 
array(':username' => $username, 
'password' => $password, 
'email' => $email, 
'date' => $date, 
'type' => 'staff' // this is the line I added, just ensuring the user is 'staff'
));
原始代码完全相同,没有
'type'=>'staff'
行。当运行此操作时,当我检查时,其余的值仍然正确地保存在数据库中,但是
type
列仍然为空。当我尝试注册用户时,出现以下错误:

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in... line database.class.php 71.
在警告之后,我进行了检查,但在
database.class.php
文件的第71行中,仅此而已:

/* Execute Query & check for any errors */
if(!$this->statement->execute()){ //this is line 71
    $result = array(
        1 => 'false',
        2 => '<b>[DATABASE] Error - Query:</b> There was an error in sql syntax',
    );
    return $result;
/*执行查询并检查是否有任何错误*/
如果(!$this->statement->execute()){//这是第71行
$result=数组(
1=>“假”,
2=>“[数据库]错误-查询:sql语法中有错误”,
);
返回$result;

我是PDO的新手,我也可以查看教程(并且已经查看过),但我还不能简单地解决这个问题。可能有什么问题,有人有什么想法吗?如果你熟悉PDO,你会寻找什么?

你需要在查询的这一部分添加:键入。值(:用户名,:密码,:电子邮件,:日期)它应该与insert语句第一部分中提供的列的顺序相匹配。@datasage-当使用命名占位符时,顺序并不重要。@Charles-是的,你是正确的。如果在准备的语句中使用索引占位符,顺序很重要。@datasage,我已经这样做了,添加了:type(检查我编辑的问题),但没有区别。