Php+mysql storage Data Common Chinese garbled problem summary,
This paper summarizes the common Chinese garbled problem of php+mysql stored data. Share to everyone for your reference, as follows:
Php+mysql common causes of garbled Chinese:
1. mysql database encoding is UTF8, and PHP Web page encoding format inconsistent, will cause MySQL in the Chinese garbled.
2. Using MySQL to create a table, or select a field when the type is not utf8, and the page encoding is not UTF8, can also cause MySQL Chinese garbled.
3. The character set of the PHP page is inconsistent with the database encoding.
4. PHP connection MySQL database, operation is set the statement specified encoding and page encoding, PHP page encoding inconsistent.
5. User-submitted HTML page encoding, and display data page encoding inconsistent, it will certainly cause PHP page garbled.
How to solve the Chinese garbled problem:
1. Page encoding settings. Attributes are typically added to the header of a file in HTML code:
Ensure that the webpage is "utf-8" encoded.
2. PHP code settings. Add the following code to the beginning of the PHP code:
Header ("Content-type:text/html;charset=utf-8");
and required to save the file encoding method is Utf-8 (can be opened with editplus settings, such as), so that the file is also utf-8 encoding.
3. The field in the table in the database stores the part of Chinese, to be set to the Utf8_general_ci type.
4.PHP When you connect to a database operation, the field type to set the operation is UTF8, as follows:
mysql_connect (' localhost ', ' user ', ' password '); mysql_select_db (' db '); mysql_query ("Set names UTF8"); * * Set the character set ***mysql_query (SQL statement to execute);
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1136649.html www.bkjia.com true http://www.bkjia.com/PHPjc/1136649.html techarticle php+mysql Storage Data Common Chinese garbled problem summary, this article summarizes the Php+mysql storage data Common Chinese garbled problem. Share to everyone for your reference, as follows: Php+mys ...