$str = \'BEGIN This is a \"quote\" test. \\\'Single\\\' END\'; echo $str . \"\\n\"; echo mysql_real_escape_string($str); // Outputs: BEGIN This is a \"quote\" test.
Sounds like magic quotes got turned on.
This post details your problem exactly, along with fixes. http://www.sitepoint.com/forums/showthread.php?t=545824