从MySQL DB检索值时获取错误的编码字符 [英] Getting incorrectly encoded characters when retrieving values from MySQL DB

查看:114
本文介绍了从MySQL DB检索值时获取错误的编码字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



显示我的网页时,所有字符都正确显示,但从我的MySQL数据库检索的值,例如Árbol不正确地渲染ás和非零的ANSI字符(作为黑色的romboid)。我使用PHP我的管理员手动将值存储在数据库中。



可能导致数据库出现此问题的原因是什么?是否有任何更改我必须做使数据库utf8准备?

解决方案

连接到服务器后,使用以下命令查看当前的客户端字符集

  

要设置它,请使用以下命令:

  set names utf8; 


I'm encoding all my files in UTF-8 without BOM.

All characters appear correctly when displaying my page, yet values retrieved from my MySQL database such as Árbol render Ás and nont ANSI characters incorrectly (as a black romboid). I'm storing values in database with PHP My Admin manually.

What can be causing this issue with the database? Are there any changes I must do to make the database "utf8-ready"?

解决方案

After you connect to the server, use the following command to view your current client characterset:

status;

To set it, use the following command:

set names utf8;

这篇关于从MySQL DB检索值时获取错误的编码字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆