Replace special character
MySQL accepts ' and " interchangeably.  So use ' to quote " and " to quote ':

REPLACE(text, "'", '"')


(There are many other solutions, involving hex, conversions, etc, but the above seems simple and straightforward.)

But...  The error message does not look like a MySQL error, so I suspect your query is in a quoted string in your client language.  So...

What client language?  Does it use backslash (\) for escaping things?