Sounds a lot like a MySQL syntax error, not a PHP syntax error.
If this is the case, then you aren't properly escaping incoming data before using it in a MySQL query. Not only should you escape string delimiters (e.g. single quotes as is the usual case in a MySQL query), but MySQL queries also require special attention; you should never place user-supplied data directly into a SQL query. Instead, you should first sanitize it with a function such as [man]mysql_real_escape_string/man.
Incidentally, by protecting yourself from SQL injection attacks, you will also resolve the issue of incoming data containing a single quote and causes syntax errors.