bla*_*sei 7 php mysql hosting zend-framework addslashes
我知道这听起来很普通而且非常微不足道,但我在这里遇到了挑战.我有一个Zend/Doctrine的网站,我使用ckeditor进行后端管理.上传网站后,我意识到在编辑测试期间,网站的外观和感觉都搞砸了.
在firebug的帮助下,我看到html上都有斜线.在内联版后,外观恢复正常.有这么多文件,我无法想到在从mysql输出数据之前做其他解码.
我有什么选择来解决这个问题.该网站已经上线,我觉得有点不自然.任何人都可以提示吗?谢谢
可能是magic_quotes_gpc
.你能证实它被关闭了吗?
以下是关闭它的方法:http: //php.net/manual/en/security.magicquotes.disabling.php
设置GPC(Get/Post/Cookie)操作的magic_quotes状态.当magic_quotes打开时,所有'(单引号),(双引号),\(反斜杠)和NUL都会自动转义为反斜杠.
另外,你使用预备语句吗?PHP PDO/MySQLI将自动为您转义.取决于您正在使用的查询类型.
看来你的数据在插入数据库之前会被双重转义.您是否正在使用mysql_real_escape_string
或addslashes
在将数据插入数据库之前?如果是这样,也许你想在插入数据之前使用stripslashes:
mysql_real_escape_string(stripslashes($data));
Run Code Online (Sandbox Code Playgroud)
或者,从数据库中取出数据后理论上可以调用stripslashes:
stripslashes($data);
Run Code Online (Sandbox Code Playgroud)
但是,第二种方法不太可取.将数据正确存储在数据库中会更好.
我感谢每一个人的帮助。实际上,公认的解决方案应该是来自 @Stanislav Palatnik 的解决方案。只是它不适用于我的 .htaccess。托管服务器很好,可以将 php.ini 放入我的 public_html 中,允许我更改它。所以给@Stanislav Palatnik +1,因为他指出了这个问题。我还发现了有趣的信息,我想我会分享,以防有人发现自己处于我的情况。
\n\ninfo from: http://support.godaddy.com/groups/web-hosting/forum/topic/how-to-turn-off-magic_quotes_gpc/\nYes \xe2\x80\x93 the solution below worked for me:\n\n(1) First of all do not try to turn off the magic quotes in your .htaccess file, it won\xe2\x80\x99t work on godaddy.\n(2) Second, if you\xe2\x80\x99re running PHP5 on your account, rename your php.ini file to php5.ini, make sure it\xe2\x80\x99s in your root folder.\n(3) Third, make sure all the lines in your php5.ini file end in a semi colon ;\n(4) Fourth, add this line to your php5.ini file:\nmagic_quotes_gpc = Off;\n
Run Code Online (Sandbox Code Playgroud)\n\n在同一页面上,有人说它不应该只是 magic_quotes_gpc,还应该是其他的,如下所示:
\n\nmagic_quotes_gpc = Off;\nmagic_quotes_runtime = Off;\nmagic_quotes_sybase = Off;\n
Run Code Online (Sandbox Code Playgroud)\n\n希望这对某人有帮助。特别感谢@Stanislav Palatnik
\n 归档时间: |
|
查看次数: |
11647 次 |
最近记录: |