Skip to content
Advertisement

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens – help needed

I’ve tried making a website which has a database connected to it and I’m getting the error message below

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

This is my PHP code that I have written below

Advertisement

Answer

It took me a while to find, but I believe that PDO::prepare passes the named parameters through a regular expression [:][a-zA-Z0-9_]+. https://github.com/php/php-src/blob/master/ext/pdo/pdo_sql_parser.re#L48. Your diacritic characters are being clobbered.

The only alternative that I know about it to use unnamed placeholders instead – ?. Something like:

Which will produce:

INSERT INTO Diák (oktatási_id, vezeték_név, kereszt_név, évfolyam, születési_dátum, város, utca, házszám, irányítószám, szak, kar) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

You’ll then have to change your execute method as follows:

$statement->execute(array_values($new_user));

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement