 <p>When you are storing code in MySQL wrap the input in the <code>addslashes()</code> PHP function. Then when you retrieve code from MySQL you need to wrap the output in <code>stripslashes()</code>. </p> <p>See: <a href="http://www.php.net/stripslashes" rel="nofollow">http://www.php.net/stripslashes</a> <a href="http://li1.php.net/addslashes" rel="nofollow">http://li1.php.net/addslashes</a></p> <p>Hopefully this is what you were looking for.</p>