問題描述
可能的重復:
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 問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!