問(wèn)題描述
可能的重復(fù):
UTF-8 全程
我正在其他人已經(jīng)開(kāi)發(fā)的網(wǎng)站上開(kāi)發(fā)一些新功能.
I'm developing some new features on a website that somebody else already developed.
字符集有問(wèn)題.
我看到數(shù)據(jù)庫(kù)有一些表格是utf8的,有些表格是latin1的
I saw that the database had some tables in utf8 and some in latin1
所以我正在嘗試將所有表格轉(zhuǎn)換為 UTF8.
So I'm trying to convert all the tables in UTF8.
我做了一張表(現(xiàn)在這張表的字段也是utf8),但沒(méi)有成功.
I did it for one table (also the fields of this table now are utf8), but was not successful.
我使用的是普通的 mysql 連接.我必須把任何配置說(shuō)它必須用utf8連接到數(shù)據(jù)庫(kù)?如果是女巫一?
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" />
看起來(lái)有些字母有效,而有些則顯示問(wèn)號(hào).例如,它無(wú)法顯示與此不同的 ' '
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: '
推薦答案
試試這個(gè)
<?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);
?>
這篇關(guān)于PHP mysql 字符集 utf8 問(wèn)題的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!