Garbled, there is garbled in the database, page extraction data garbled and other display normal, phpMyAdmin also show normal, and so on.
Database, Web page encoding inconsistency caused the assumption that using Utf-8 encoding (your uploaded php file using utf-8 encoding) to connect to the database with mysql_query ("SET NAMES ' UTF8 '"), and at the front of the page with <?php header (' Content-type:text/html;charset=utf-8 ');? >[object object]<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
This encounter situation is phpmyadmin in the normal display, the page from the database extracted from the Chinese garbled for? , other display normal, first look at the database used in the character set and the database collation encoding format, and the page output when the character encoding set the same, there is no problem, still garbled, so I think, may be in the database to extract data from the encoding format is problematic, Then find the database connection file on the character encoding settings, found no setting, so use mysql_query ("Set names gb2312"); The data extracted from the database in gb2312 encoding format output, at this time also page set encoding format is the same, the page normal display.
PHP read MySQL data to page garbled