将html内容保存在mysql数据库中 [英] saving html content in mysql database
问题描述
我正在使用php并尝试在mysql数据库中保存一些html内容. html内容是由ckeditor生成的.内容是这样的-
I am using php and trying save some html contents in mysql database. the html content is generating by ckeditor. The content is something like this-
<p><img align="left" alt="" src="images/1im1.jpg" style="margin:1px 15px 0 0; border:1px solid #cecece; " /> <img alt="If syou love hot sauce" src="images/tit_If-you-love-hot-sauce.jpg" /></p><br>D'elidas is a fine<p>
我正在php-
$main_data = mysql_real_escape_string($_POST['content']);
这在我的本地主机(xampp)中工作正常.但不能在线工作.我的主机正在使用最新版本的PHP和MySQL.保存在在线数据库中后,我会看到这样的
This was working okay in my localhost(xampp). but not working in online. my hosting is using latest version of PHP and MySQL. after saving in online database, I see like this-
<p><img align=\"left\" alt=\"\" src=\"images/1im1.jpg\" style=\"margin:1px 15px 0 0; border:1px solid #cecece; \" /> <img alt=\"If syou love hot sauce\" src=\"images/tit_If-you-love-hot-sauce.jpg\" /></p>br>D\'elidas is a fine<p>
这就是为什么HTML无法在我的页面中正确显示的原因.请帮我解决这个问题.这是在引号之前添加斜线.我想保存确切的html并显示在前端.
And that is why the HTML is not displaying correctly in my page. Please help me about this. this is adding slashes before quotes. I want to save exact html and show in front end.
推荐答案
您的托管公司可能已打开魔术引号- http://php.net/manual/en/security.magicquotes.php
You hosting company probably has magic quotes turned on - http://php.net/manual/en/security.magicquotes.php
You can't disable it in code, but Example 2 here shows a work around http://www.php.net/manual/en/security.magicquotes.disabling.php
这篇关于将html内容保存在mysql数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!