Environment: The methods below UbuntuLinux have been tested by myself, which can solve the problem of inserting MySQL database garbled characters in UbuntuPHP. 1. use utf8 for database storage whenever possible (modify/etc/my. cnf: Add default-character-set = utf8 in the [mysqld] segment (convert existing databases to UTF8 format first) 2. before the PHP program queries the database, execute mysql_query ("setnamesxxxx"); where xx
Environment: Ubuntu Linux
The following methods have been tested by myself and can solve the problem of garbled characters in Ubuntu PHP inserting MySQL database.
1. Use utf8 for database storage as much as possible (modify/etc/my. cnf and add default-character-set = utf8 in the [mysqld] segment) (convert existing databases to UTF8 format first)
2. before the PHP program queries the database, execute mysql_query ("set names xxxx"). xxxx indicates the code of Your webpage (charset = xxxx). If charset = utf8 In the webpage, then xxxx = utf8. If charset = gb2312 In the webpage, xxxx = gb2312
Almost all WEB programs have a piece of public code to connect to the database. Put it in a file and add mysql_query ("set names") to the file.
3. PHPMyAdmin does not need to be modified.
4. Note that to ensure the actual encoding of the webpage (encoding in the Windows save dialog box) and its declared encoding (charset = ?) Yes. use tools such as DW for Web pages.