dox90448
2016-11-10 13:36
浏览 41
已采纳

UTF8 mysql编码的数据库字段只显示php页面中的特殊字符

I have a database field with utf8_unicode_ci encoding in MySQL. This arrangements done by the previous developer and it's store arabic language data in some special character format like this:

رنا كلبونه

I have set the headers to <meta http-equiv="Content-type" value="text/html; charset=utf-8" /> but its not showing the arabic language characters when I try to fetch the values from the database. It's only showing these special characters instead of the language.

图片转代码服务由CSDN问答提供 功能建议

我在MySQL中有一个带有 utf8_unicode_ci 编码的数据库字段。 这个安排是由前一个开发人员完成的,它以一些特殊的字符格式存储阿拉伯语言数据,如:

رناكٓب†‡‡ / strong>

我已将标头设置为&lt; meta http-equiv =“Content-type”value =“text / html; charset = utf-8”/&gt ; 但是当我尝试从数据库中获取值时,它没有显示阿拉伯语言字符。 它只显示这些特殊字符而不是语言。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dougang5088 2016-11-12 11:14
    已采纳

    If you are using MySQL then use below after DB connection

    mysql_query("SET NAMES utf8");

    If you are using MySQLi then use below after DB connection

    mysqli_set_charset($connection,"utf8");
    

    If you are using class and object of mysqli then use below

    $mysqli = new mysqli("localhost", "root", "", "test");
    $mysqli->set_charset("utf8");
    

    Hope this will help !

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题