PHP mysql charset utf8 problems(PHP mysql 字符集 utf8 问题)
问题描述
可能的重复:
UTF-8 全程
我正在其他人已经开发的网站上开发一些新功能.
I'm developing some new features on a website that somebody else already developed.
字符集有问题.
我看到数据库有一些表格是utf8的,有些表格是latin1的
I saw that the database had some tables in utf8 and some in latin1
所以我正在尝试将所有表格转换为 UTF8.
So I'm trying to convert all the tables in UTF8.
我做了一张表(现在这张表的字段也是utf8),但没有成功.
I did it for one table (also the fields of this table now are utf8), but was not successful.
我使用的是普通的 mysql 连接.我必须把任何配置说它必须用utf8连接到数据库?如果是女巫一?
I'm using the normal mysql connect. I have to put any config to say that it must connect with utf8 to the DB? If yes witch one?
在我的 html 中:
In my html I have:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
看起来有些字母有效,而有些则显示问号.例如,它无法显示与此不同的 ' '
It looks like some letters works and others display the question mark. For example it not able to display this ’ that is different of this: '
推荐答案
试试这个
<?php
header('Content-Type: text/html; charset=utf-8');
?>
然后在连接中
<?php
$dbLink = mysql_connect($argHost, $argUsername, $argPassword);
mysql_query("SET character_set_results=utf8", $dbLink);
mb_language('uni');
mb_internal_encoding('UTF-8');
mysql_select_db($argDB, $dbLink);
mysql_query("set names 'utf8'",$dbLink);
?>
这篇关于PHP mysql 字符集 utf8 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP mysql 字符集 utf8 问题


基础教程推荐
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 使用 PDO 转义列名 2021-01-01