警告:PDOStatement :: execute()[pdostatement.execute]:SQLSTATE [HY093]

时间:2014-05-31 17:31:21

标签: php pdo

我在PHP中使用PDO进行以下查询:

$form = $_POST;
$alias = $form[ 'alias' ];
$nombre = $form[ 'nombre' ];
$pass = $form[ 'pass' ];
$sql = "INSERT INTO tbmeseros ( alias_mesero, nombre_mesero, pass_mesero ) VALUES (:alias,:nombre,:pass)";
}
$query = $dbh->prepare( $sql );
$query->execute(array(':alias'=>$alias,':nombre'=>$nombre,':pass'=>$pass) );//THIS IS LINE 92

但我收到警告:

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /.../NuevoAdminMeseros.php on line 92

我没有看到警告的原因,我认为这两个陈述都有三个变量。

1 个答案:

答案 0 :(得分:0)

试试这个。

$form = $_POST;
$alias = $form['alias'];
$nombre = $form['nombre'];
$pass = $form['pass'];
$sql = "INSERT INTO tbmeseros (alias_mesero, nombre_mesero, pass_mesero) VALUES (:alias,:nombre,:pass)";
$query = $dbh->prepare($sql);
$query->execute(array(':alias' => $alias,':nombre' => $nombre,':pass' => $pass));