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.

  • 写回答

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 !

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改