【发布时间】:2017-03-10 06:39:43
【问题描述】:
我有一个add_post 表单,其中包括post_title、post_content 和date。 post_content 可能包含 special_characters 和 HTML 元素
存储到 post_content 有问题
示例字符串:
健身房围绕着这个称为“社区”的独特因素展开。
如果我尝试将该字符串插入到数据库表中,则会插入以下字符串:
健身房围绕着这个独特的因素,称为
由于符号(“”’)我无法插入所有数据
我只想删除这些符号,以便能够添加所有 post_content 数据
这是我尝试过的:
$post_content=$_POST['post_content'];
$post_content=addslashes($post_content);
$post_content=htmlentities($post_content);
【问题讨论】:
-
如何将数据插入数据库?您使用的是哪个数据库?您的数据库中的哪个字符集?您的问题不清楚,也没有显示出任何研究成果。
-
您在下面的几个 cmets 中提到您尝试过
mysql_real_escape_string,但没有成功。请清楚地解释这不起作用的原因和原因 -
$this->db->insert('posts', $data); -
@deep 3015 的解决方案应该适合你
标签: php mysql codeigniter