Jonas
Jonas

Reputation: 82

Can't insert a row in database

I've got a little problem.

My php script won't insert a row in the database.

Here is my script:

INSERT INTO Keys (Key, Id1, Id2, Id3, Id4, Id5) 
VALUES ('kjlkjl', 986, 87, 7, 8, 5)

Hastebin script

I always get the error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Keys (Key, Id1, Id2, Id3, Id4, Id5) VALUES ('kjlkjl', 986, 87, 7, 8, 5)' at line 1

Is there a way that I can fix this? I've tried all the possibilities to do it (MySQLi Object-oriented, MySQLi Procedural and PDO)

Thanks for your time, Jonas

Upvotes: 0

Views: 71

Answers (1)

Wajdi Ben Abdallah
Wajdi Ben Abdallah

Reputation: 297

The reason is that you are using a reserved keyword for mySQL (key : the name of first column), try to change it to another keyword ('identifiant' for example), remember that there's some keywords reserved for mySQL like table, column, row, avoid using them as names.

Upvotes: 1

Related Questions