Skip to content
Advertisement

SQL syntax error. check corresponds to MYSQL server

I try to do a form which can insert data into database. After I insert a dummy data the is come out.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

This error are make me in trouble. My database are not inserted any record

Advertisement

Answer

You’ve set your $table variable inside single quotes while using a reserved word, column for your table name $table = "column";

Use backticks around it, like so:

either do that or give your table another name.


You also have a quote missing here '$Author, so do '$Author',

Also, you can remove mysqli_query($conn,$sql); since you’re already using
if (!mysqli_query($conn,$sql))


Footnotes:

Your present code is open to SQL injection. I strongly suggest that you use prepared statements, or PDO with prepared statements.

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