[英]PHP UTF8 Database
我有一個以UTF8_bin編碼的數據庫。 每當我嘗試在該數據庫上回顯某些內容時,我都會得到問號而不是字母。 有人知道解決方案嗎? 我認為必須提及的一點是,如果我確實在UTF8中回顯一個單詞,那就很好了。 問題是從數據庫獲取數據。
請檢查您是否已遵循這些步驟。
-> db collation must be utf8_general_ci
-> then collation of the table with language has to be utf8_general_ci
-> in your php connection script put header('Content-Type: text/html; charset=utf-8');
-> in xhtml head tag put <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-> after selecting the db in the connection script put mysql_query("SET NAMES 'utf8'");
Then check the connection like this,
if(!mysqli_set_charset($conn, 'utf8')) {
echo 'the connection is not in utf8';
exit();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.