Chris Born
Chris Born

Reputation: 11

PDO does not recognize column with special character

I'm trying to create an application with SimpleMVC (PHP Framework) and in the database there is a column with the name "contraseña". When trying to make any query in this column, the PDO returns this error:

SQLSTATE [HY093]: Invalid parameter number: parameter was not defined

There is how to make the PDO recognize special characters?

Controller:

$servidor = array(
 'cuenta' => $usuario,
 'contraseña' => $senha,
 'ipRegistro' => $ip,
 'apodo' => $apelido
);
$this->_model->insert_server($servidor);

Model:

public function insert_server($data) {
 $this->_db->insert("cuentas",$data);
}

Link to the SimpleMVC Framework: PHP Framework - SimpleMVC

Upvotes: 0

Views: 154

Answers (1)

Tserkov
Tserkov

Reputation: 446

Wrap the column bame in backticks, like so:

$servidor = array(
 'cuenta' => $usuario,
 '`contraseña`' => $senha,
 'ipRegistro' => $ip,
 'apodo' => $apelido
);

Might be something worth mentioning to the SimpleMVC developers.

Upvotes: 2

Related Questions