Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在数据库中插入富格文本编辑器中的代码_Php_Mysql_Database_Rich Text Editor - Fatal编程技术网

Php 在数据库中插入富格文本编辑器中的代码

Php 在数据库中插入富格文本编辑器中的代码,php,mysql,database,rich-text-editor,Php,Mysql,Database,Rich Text Editor,我使用tinymce作为我提交一些新闻的表单,但它不会将其插入数据库 我检查了SQL,它只是试图将代码插入数据库。有点像 INSERT INTO news (news_title, news, time_added) VALUES (some title, `<p>some text <strong>some strong text</strong></p>`, NOW()) 插入到新闻(添加了新闻标题、新闻、时间)值(一些标题,`一些文本一些强

我使用tinymce作为我提交一些新闻的表单,但它不会将其插入数据库 我检查了SQL,它只是试图将代码插入数据库。有点像

INSERT INTO news (news_title, news, time_added) VALUES (some title, `<p>some text <strong>some strong text</strong></p>`, NOW())
插入到新闻(添加了新闻标题、新闻、时间)值(一些标题,`一些文本一些强文本

`,NOW())
它只是不把它插入数据库
有人能告诉我为什么以及我必须做什么吗?

您需要对内容进行html编码,然后插入

使用类似于
htmlentities($str)

例如:

encodedStr = htmlentities($html);
要解码:

$html = html_entity_decode($encodedStr);

是的,所以当您打印时,您需要将原始html转换回未转换的表单a=htmlentities($orig)$b=html实体解码($a);使用事先准备好的陈述。还提供您正在尝试执行的操作的代码。