Home >Backend Development >PHP Tutorial >General solutions when php and mysql encounter garbled characters

General solutions when php and mysql encounter garbled characters

WBOY
WBOYOriginal
2016-07-25 09:02:57866browse
When it comes to solving garbled codes in PHP and MySQL, we need to analyze the reasons for the garbled codes. The MySQL database has its own data storage encoding format, the computer has its own encoding method, and the web page has its own method. When these three are not unified When , a garbled code problem occurs...

When it comes to solving garbled codes in PHP and MySQL, we need to analyze the reasons for the garbled codes. The MySQL database has its own data storage encoding format, the computer has its own encoding method, and the web page has its own method. When these three do not When unified, garbled codes will occur. The garbled codes mentioned here mainly refer to incorrect Chinese display.

Under normal circumstances, if we want to display Chinese, we should select utf-8 as the encoding method of the web page, and utf8_unicode_ci as the database encoding method. At the same time, we should pay attention to when inserting data into the database, we must first execute mysql_query("set names utf8"); so that the database can correctly store Chinese.



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