我从PHP运行这个确切的查询中删除斜杠:Mysql的似乎从字符串
UPDATE commentedText SET title='§2.', content='<div class=\"pageParagraph\"><p>Test</p>\n</div>', last_changed='1430422172', image_banner_url='', active='', comments='[{"from":"0","to":"0","id":"1","CommentedText":"","comment":"New test with \"test\" :d"}]' WHERE id='5541d52beb2ea' AND appId='MyAppID' LIMIT 1
然而,当我读到被更新(通过PHP或MySQL工作台)行,斜线都不见了。例如见
<div class=\"pageParagraph\"[..]
其保存到表作为
<div class="pageParagraph"[..]
为什么斜线消失?
斜线用于转义插入字符。要插入文字斜杠,您需要将它们转义\ \这就是为什么您使用准备好的语句或至少使用'escape_string'函数。 – AbraCadaver
因为在执行查询或使用准备好的语句(推荐)时没有正确转义字符串,它们会消失。参见[PDO](http://php.net/manual/en/pdo.prepared-statements.php)或[this for mysqli](http://php.net/manual/en/mysqli.quickstart。制备-statements.php)。如果你使用'mysql_ *'函数,一定要切换到其中一个。 – Mike