Php 如何将符号保存并回显到数据库中的符号数据
我有一个带有textarea的简单表单 例如:Php 如何将符号保存并回显到数据库中的符号数据,php,mysql,textarea,special-characters,Php,Mysql,Textarea,Special Characters,我有一个带有textarea的简单表单 例如: <textarea name="script"></textarea> 当第一次在DB中添加脚本时-一切正常,但当我编辑它时,在“中转换 有没有办法保存和编辑这些数据,并保留每个字符 更新:如何通过该帖子发送 <textarea name="script">"</textarea> ” 使用htmlentities()和html\u entity\u decode()存储在数据
<textarea name="script"></textarea>
当第一次在DB中添加脚本时-一切正常,但当我编辑它时,在“
中转换
有没有办法保存和编辑这些数据,并保留每个字符
更新:如何通过该帖子发送
<textarea name="script">"</textarea>
”
使用htmlentities()
和html\u entity\u decode()
存储在数据库中
$orig = "I'll \"walk\" the <b>dog</b> now";
$a = htmlentities($orig);
$b = html_entity_decode($a);
echo $a; // I'll "walk" the <b>dog</b> now
echo $b; // I'll "walk" the <b>dog</b> now
$orig=“我现在就去遛狗”;
$a=htmlentities($orig);
$b=html_实体_解码($a);
回声$a;//我现在“走”b日志/b
回声$b;//我现在就去遛狗
这看起来像是工作,但不要。核心问题似乎出现在textarea,当我第一次从DB回显数据时,所有数据都正确:replace(/“/g,”)代码>但当我再次提交表单时,在“
。为什么使用replace
函数,请给出php
代码,用于存储和检索数据库中的数据。这将帮助我找出并测试它。@Tahiaji最后一个版本是写入数据:mysql\u查询(“更新FOTtable SET value=”。base64\u编码(htmlentities($value)).“'WHERE object='”、“$object.”代码>和读取数据:html_实体_解码(base64_解码($this->read_one(“从FOTtable中选择值,其中object='“$object.”))代码>
$orig = "I'll \"walk\" the <b>dog</b> now";
$a = htmlentities($orig);
$b = html_entity_decode($a);
echo $a; // I'll "walk" the <b>dog</b> now
echo $b; // I'll "walk" the <b>dog</b> now