Hello! I'm working on a simple messaging system for a project and I have this query and it isn't working for some odd reason, here it is:

mysql_query("INSERT INTO messages SET

Here is my 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 'to='4', private='0'' at line 5

Not quite sure what it's saying, I'm not trying anything new I'm using the same syntax as I always do in my queries. But I know me I might just need someone to point something obvious out, but who knows. Thanks for any help, and sorry if it's obvious! (And yes I have tested all variables being used, they are valid.)

4 Years
Discussion Span
Last Post by NardCake

it looks to me that $checked = a variable with an extra ' in it. It says it in the message (private='0'') with the extra aposrophe. Maybe thats why?


Nope thats not it, echoed it out, it's an integer as it was supposed to be. Thanks for the suggestion though! Any other ideas anyone?


Nothing is standing out, the only thing I can think of is mix-matching a field. Make sure your DB cols are of the correct type for the data your supplying... i.e. the to col isn't of type CHAR or something to the effect


GliderPilot, thanks for bringing that to mind. That was indeed the issue, you see the $id value placed in the private field was not the correct data. After tracing it back from a javascript file to another PHP file I have discovered I have used the incorrect variable. Thanks for the suggestions!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.