0
我有一個以UTF8_bin編碼的數據庫。 每當我嘗試在該數據庫上回顯某些內容時,我會收到問號而不是字母。任何人都知道這個解決方案?我認爲有必要提一下,如果我在UTF8中迴應一個單詞,那就好了。問題是從數據庫獲取數據。PHP UTF8數據庫
我有一個以UTF8_bin編碼的數據庫。 每當我嘗試在該數據庫上回顯某些內容時,我會收到問號而不是字母。任何人都知道這個解決方案?我認爲有必要提一下,如果我在UTF8中迴應一個單詞,那就好了。問題是從數據庫獲取數據。PHP 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();
}