php - mysql/php 的 UTF8 问题

标签 php mysql utf-8 character-encoding

我有一个 mysql 表,其中包含一些导入的数据,特别是一个值是 Sinn Féin

我的数据库使用的字符集是utf8_general_ci 。数据在 phpMyAdmin 中显示良好。在我的网站中,我使用了 PHP header header("Content-type: text/html; charset='utf-8'"); 。我有<meta http-equiv="Content-type" content="text/html; charset=utf-8" />在我的<head> .

我的数据仍然显示为 Sinn F�in 。我尝试过使用 utf8_decode ,但这没有帮助。我做错了什么?

最佳答案

mysql_connect()之后添加以下行:

mysql_query ("SET NAMES utf8");

关于php - mysql/php 的 UTF8 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8616656/

相关文章:

php - Magento如何同步订单另一个mysql数据库

java - "illegal character:\65279"在 Maven 编译期间尽管设置为 UTF-8

php - 数据库中的引号被回显为 Chrome 中的菱形问号

php - 在后台线程/进程中调用函数( fork )

php - 当值有单引号时,显示数据库中的不完整值,

php - Wordpress - 覆盖主题 CSS 样式表

python - Django / python : catch MySQL IntegrityError

php - 当这些卡保存从 mysql 数据库中获取的数据时,如何连续排列具体化 css 卡

php - MySQL 表格单元格添加

ruby - Ruby 中的 GSM-7 转换和 septet 编码库?