I have this problem, on my website i try to comment on a profile page, but when i click to submit it, it says
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 'to, msg, author,time)
VALUES ('52', Test','Sakaio911', NOW())' at line 1
All I'm doing is inserting the comment into the database, and you can see what columns. Is it the NOW() that causes it because i have no idea what im doing wrong.
The error message points you to the 'to' column name. According to the documentation, that name is reserved as a key-word. You will probably want to rename that col, or you will have to do some gymnastics to use that table.
Make sure you have a semicolon both for the sql query and the php code line itself.One semicolon inside the " " marks and the other outside to terminate the line of code.
Wrap the field names with back ticks ... so for example `to`,`msg` etc. That should solve that particular problem.
('52', Test','Sakaio911', NOW())'
The insert statement uses commas as delimiters for the field names and their values. It appears that you're missing something between the '52' and the Test'. Are you short a single quote before Test' or should the entire string be in double quotes like this? "This'".
When you don't want to rename your column name, you must escape it in context by `
... `to`, msg, author, time) VALUES ('52', 'Test','Sakaio911', NOW())