Solutions for php connection to mysql garbled characters. Many friends may encounter garbled characters when they connect to the database for reading or writing at the early stage of learning PHP, today, I am here to tell you the simplest way to solve the garbled text problem. phpmyadmi many of my friends will encounter garbled text when they connect to the database to read or write PHP at the early stage, today, the editor is here to tell you the simplest way to solve the garbled text problem.
Use phpmyadmin to add a mysql database, and then use php to operate the database. the solution is garbled:
1: confirm that the mysql character set used by phpmyadmin is UTF-8 unicode (utf8), the mysql connection is utf8_general_ci, and the language is chinese-chinese simplified.
2: confirm that each data table is "utf8_general_ci;
3: add a statement after connecting to the mysql database in php to specify the character set of the database,
Example: $ conn = mysql_connect ("localhost", "root", "your password"); // connect to the database
Mysql_query ("set name utf8 ");
Using phpmyadmi...