Home >Database >phpMyAdmin >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.xixiOriginal
2020-07-20 13:54:332127browse

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

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

2. The PHP page is saved using utf-8 encoding 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 to utf-8_general_ci

4. When connecting to the database in PHP, that is, add <pre class="brush:php;toolbar:false">mysql_query(&quot;set names ’utf8’ &quot;); mysql_query(&quot;set character_set_client=utf8&quot;); mysql_query(&quot;set character_set_results=utf8&quot;);mysql_query(&quot;set character_set_connection=utf8&quot;);</pre> 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