Home>Article>Database> What should I do if phpMyAdmin MySQL is garbled under PHP?

What should I do if phpMyAdmin MySQL is garbled under PHP?

coldplay.xixi
coldplay.xixi Original
2020-07-20 13:54:33 1966browse

Solution to phpMyAdmin MySQL garbled code under PHP: First set the encoding for the web page file head; then use [utf-8] encoding to save when saving; then set the database related fields to [utf-8_general_ci]; finally Just add the relevant code when connecting to the database in PHP.

What should I do if phpMyAdmin MySQL is garbled under PHP?

Solution to phpMyAdmin MySQL garbled code under PHP:

1. Web page file head setting encoding

2. The PHP page is saved usingutf-8encoding when saving, and can be converted using notepad or other text editing software.

notepad operation: menu "Format" -> "Convert to UTF-8 encoding format"

3. The "Organization" of the fields in the database table is set toutf-8_general_ci

4. When connecting to the database in PHP, that is, add

mysql_query("set names ’utf8’ "); mysql_query("set character_set_client=utf8"); mysql_query("set character_set_results=utf8");mysql_query("set character_set_connection=utf8");
after

mysql_connect()

. Note that it is utf8, not utf-8.

Related tutorial recommendations:phpmyadmin

The above is the detailed content of What should I do if phpMyAdmin MySQL is garbled under PHP?. For more information, please follow other related articles on the PHP Chinese website!

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