Why mysql doesn't execute the query?

Viewed 339

Why is this query not working? Where's the problem?

The host uses MySql 5.7

INSERT INTO richieste(email, stato, tipo, database, logreg, animazioni, desc, titolo) 
VALUES('1', '2', '3', '4', '5', '6', '7', '8')

Database structure:

id  int(11) No       
email   int(11) No       
stato   int(11) No       
tipo    int(11) No       
database    int(11) No       
logreg  int(11) No       
animazioni  int(11) No       
desc    int(11) No       
titolo  int(11) No 

Error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database, logreg, animazioni, desc, titolo) VALUES('1', '2', '3', '4', '5', '6',' at line 1

How can I fix this?

1 Answers

Try to avoid using MySQL Reserved Keywords as table or column names. You're using database here, which is a keyword, so it must be escaped, while desc should be as well:

INSERT INTO richieste(email, stato, tipo, `database`, logreg, animazioni, `desc`, titolo)

You'll have to do this every time you reference these columns so if it's not too late, rename them to something that doesn't conflict.

Related