"You have an error in your SQL syntax near..."
allthough you say there is no error in you're query, there is!!! otherwise it wouldn't be saying that. It is probably has something to do with quotes.
Printout the query on you're page so you know exactly what php is executing, then "fix" the problem.