2014-10-19 81 views
0

我有一个以UTF8_bin编码的数据库。 每当我尝试在该数据库上回显某些内容时,我会收到问号而不是字母。任何人都知道这个解决方案?我认为有必要提一下,如果我在UTF8中回应一个单词,那就好了。问题是从数据库获取数据。PHP UTF8数据库

回答

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(); 
      }