Home  >  Article  >  Backend Development  >  Explanation on how to solve the problem of garbled characters in PHP connection to MySQL_PHP Tutorial

Explanation on how to solve the problem of garbled characters in PHP connection to MySQL_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:40:34759browse

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");

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486204.htmlTechArticleMany friends in the early days of learning PHP, there will always be garbled characters when connecting to the database to read or write. Today's editor Here I will tell you the simplest way to solve the problem of garbled characters using phpmyadmi...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn