我有一个以UTF8_bin编码的数据库。 每当我尝试在该数据库上回应一些东西时,我会得到问号而不是字母。有人知道解决方案吗?我认为重要的是要提一下,如果我回答UTF8中的一个单词,那就没关系了。问题是从数据库获取数据。
答案 0 :(得分:0)
请检查您是否已按照这些步骤操作。
-> 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();
}