Solution to php connection to mysql garbled code _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.