Consensus: 1. First of all, it should be determined that Chinese should also be stored with varchar.
2. Test using MySQL statement to view character set
show variables like "%char%";
show variables like "collatio%";
If you look at a place where the encoding is not uniform (Chinese app GBK or UTF8 support), you can modify the value of an item specifically, for example:
SET character_set_client='utf8';
1. Create a database
CREATEDATABASE databasenameCHARACTERSET'utf8'COLLATE'utf8_general_ci';
2. Create a table
CREATE TABLE industry_name ( ... ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
The only difference between this place and the normal table is the last word.
Test to see if UTF8 unified
—————— can now display Chinese in MySQL when viewed —————-
And try to get the Chinese in PHP.
1. Write in the previous section of the Code
header("Content-Typetext/html;charset=utf8");
2. After the establishment of connection, write
mysqli_query($connection"SET NAMES utf8");
———— can now display Chinese in the PHP page ————-
Finally, if you need to use Json_encode, you need to pay attention to the last point
$json_string = json_encode($result_row, JSON_UNESCAPED_UNICODE);
That is, in the ordinary json_encode to add a parameter, so it is all done ~
Reference article:
Go MySQL Chinese garbled problem perfect solution (including build library, import data, Web page)
Completely solve the MySQL Chinese garbled method
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the creation from the database to PHP read Json_encode Chinese correct display, including the json_encode aspects of the content, I hope that the PHP tutorial interested in a friend helpful.