Php 在数据库中插入富格文本编辑器中的代码
我使用tinymce作为我提交一些新闻的表单,但它不会将其插入数据库 我检查了SQL,它只是试图将代码插入数据库。有点像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()) 插入到新闻(添加了新闻标题、新闻、时间)值(一些标题,`一些文本一些强
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);使用事先准备好的陈述。还提供您正在尝试执行的操作的代码。