Home >Backend Development >PHP Tutorial >Explanation on how to solve the problem of garbled characters in PHP connection to MySQL_PHP Tutorial
In the early days of learning PHP, many friends will always have garbled characters when connecting to the database to read or write. Today I will tell you the simplest way to solve the garbled code problem
Use phpmyadmin to add the mysql database, and then use Solution to garbled characters in PHP operation database:
1: Confirm that the mysql character set used by phpmyadmin is utf-8 unicode (utf8); the mysql connection proofreading is utf8_general_ci, and the language is Chinese-chinese simplified
2: Confirm that each The data table is "organized into" utf8_general_ci;
3: Add a statement after php connects to the mysql database to specify the character set of the database,
For example: $conn=mysql_connect("localhost","root","you Password"); //Connect to the database
mysql_query("set name utf8");