dongwen7380 2013-09-30 05:29
浏览 67

使用php无法从mysql数据库中显示特殊字符

I apologize if this is a duplicate question. I am a newbie to special characters and know very little about special character encoding and decoding. I looked all over stackoverflow, tried the solutions but still cannot solve my problem. I have stored special characters in my mysql database, like prēməˈCHo͝or/,/-ˈt(y)o͝or. Database collation is utf8_bin. It shows fine in my database field but on my page, it displays as ?pr?m??CHo?or/,/-?t(y)o?or. I have added the following line to display this field:

<?php 
echo strip_tags(html_entity_decode($row->Phonetic_eng,ENT_QUOTES, "UTF-8")); 
?>

I have also added this to the php file:

<html><head><meta http-equiv="Content-type" content="text/html;charset=UTF-8"></head></html>

Kindly note that saving to database is not the issue I think. It is displaying the data that is the problem I think. In that case, how should I write the display statement:

<?php 
echo strip_tags(html_entity_decode($row->Phonetic_eng,ENT_QUOTES, "UTF-8")); 
?>

I would really appreciate any help. Thank you in advance

  • 写回答

2条回答 默认 最新

  • duana1021 2013-09-30 05:32
    关注

    After selecting database, add this:

    mysql_query("set names 'utf8'");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目