Next time when u have a problem with MySQL u can always run the query in phpmyadmin as a query and see what it gives as output.
It gives a more detailed error most of the time so u can know for sure if there is a problem with ur php syntax or the query