![](/img/trans.png)
[英]how to insert special character in mysql via php and display on html page
[英]Special character output in html from mysql
我在Wordpress中使用一个插件,在一个字段中存储一些HTML代码。 此mediumtext utf8_general_ci
当我想输出这些信息时,所有特殊字符,如" ´ ' ...
和其他一些字符显示为黑色钻石,里面有问号
当插件显示此文本时,它是完美的。 这是在头脑中:
<meta charset="UTF-8" />
当我在其他地方输出时,我的头脑中有这个,所有这些字符都丢失了:
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
字符正确存储在MYSQL中,我通过PHP输出它
ob_start();?>
some html
<?php echo $row4['details'];?> <- this is the field im talking about
some html
<?php
$details = ob_get_clean();
后来只是:
echo $details;
我已经阅读了足够的内容,并且总是提到字符集,但我认为我的还可以。
谢谢您的帮助!
编辑:添加完整示例
WP中显示的文字。 正如我在评论中所说,这可能是由编辑将MS Word复制/粘贴到Worpress中。
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, “Time is gold”?
Has… heard…
Have… hear…
Have… heard…
像这样存储在数据库中(不要查看正确/正确的用户答案)
<span class='watupro_num'>8. </span>Choose the verb to complete the sentence.</p>
<p>______ you ever _____ the proverb, “Time is gold”?</p></div>
<ul>
<li class='answer'><span class='answer'>Has… heard…</span></li>
<li class='answer user-answer'><span class='answer'>Have… hear…</span></li>
<li class='answer correct-answer'><span class='answer'>Have… heard…</span></li>
</ul>
从数据库中显示的文本(我正在进行的工作)
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, �Time is gold�?
Has� heard�
Have� hear�
Have� heard�
由于Kirit Patel,在utf8_encode()
之后显示的文字
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, Time is gold?
Has heard
Have hear
Have heard
我刚发现角色还在那里。 编辑时我可以看到一个带数字的框(未在预览中显示)。
你可以像使用一样
<?php
echo utf8_encode($row4['details']);
?>
希望这对你有所帮助。
这里讨论“黑钻石”。 “Someting like this”显示0093
,这是一个无效的utf8代码,用于某种引用的味道; 另一方面,hex 93,解释为latin1是“
。
你能简单地切换到ascii引号和撇号吗?
否则,您需要始终使用utf8 - 从生成十六进制93的任何内容开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.