If I'm right, then it's a fairly simple PHP problem.
I imagine that when you use your query in PHP you make it a string by enclosing it in double quotes - however this is a problem because your SQL query also contains double quotes.
Either replace the SQL double quotes with single quotes, or...