


phpmyadmin displays the problem of utf8_general_ci Chinese garbled characters, the final chapter_PHP tutorial
I have been writing PHP for more than a year, but the coding problem has not been solved well. My situation is like this,
The webpage display is completely normal. The Chinese garbled characters are displayed in the phpmyadmin database. Whether it is simplified or traditional, as long as it is Chinese, it is displayed in the following form: 梧州旅游
However, the webpage I wrote is displayed completely normally, whether it is Traditional Chinese or Simplified Chinese, there will be no garbled characters.
Of course, my webpage is saved in utf-8 format, and when I read the library, I added the statement mysql_query("set names 'utf-8'");, so what I see on the webpage is It is completely normal. Of course, it only displays garbled characters in phpmyadmin. If you see here that the web page is garbled, follow what I said, and save the web page in utf-8 format using Notepad, and then After specifying in the web page, add mysql_query("set names 'utf- 8'"); There will definitely be no garbled characters. Of course, databases, data tables, and fields must also be saved as utf8_general_ci encoding . Through the above operations, it will never appear on the web page. There will be garbled characters. What I am explaining here today is the problem of garbled characters displayed in phpmyadmin. This is the final article to solve the problem of garbled characters. After reading this article carefully, garbled characters will no longer appear. Appear in our programs and databases.
Okay, after reading the text part, you will definitely not have garbled characters when displayed on the web page. However, the Chinese characters displayed in phpmyadmin are still garbled. I spent a day to analyze my own code. , encoding format, and the encoding format of phpmyadmin. I searched GG and asked experienced technical personnel, but to no avail. Of course, it is better to ask for help than to ask for help. I slowly analyzed the encoding problem by myself, and finally found out why I was displaying garbled characters in phpmyadmin. Question, if you want to have a deeper understanding of encoding issues, so that garbled codes will no longer bother you in the future, you have to check these two differences: utf8 and utf-8, don’t look at them. It’s all the same, just one more line, one less line, will make your phpmyadmin garbled. Well, analyze your own garbled situation and change the red words. The following are the final methods to prevent garbled characters from appearing on the web page. Problem with garbled characters in phpmyadmin:
1 Use notepad to save all web pages as utf-8, as shown in the picture:
Note: ANSI is applicable to BIG5 and GBK
2 Specify the encoding format in your own web page. This is relatively simple. Not much to explain
3 Add mysql_query("set names 'utf8'") to the database operation; I can see clearly that it is utf8, not utf-8. For related information, use utf-8 in phpmyadmin It will be garbled characters. I have been writing programs by myself for more than a year. I have been using utf-8, which resulted in the format of garbled characters in phpmyadmin. Now I changed it back to utf8 and finally solved the problem of phpmyadmin displaying Chinese garbled characters. But there is one thing to pay attention to. After changing to utf8, the Chinese characters you previously entered will be garbled when read on the web page. If there is a lot of content, don’t change it. At most, phpmyadmin will be garbled, and the display on the web page will always be normal. Here, it is changed to utf8. When developing programs in the future, I will use this as a web page. All displays in phpmyadmin will be normal. For the garbled code problem, I would like to say 88.
4 The encoding format of the database is utf8_general_ci, the table format is also utf8_general_ci, and Chinese fields are also in utf8_general_ci,Look at phpmyadmin’s picture:
The above is the library and table load organized into utf8_general_ci, and then the field load Picture:
Okay, if you do these steps and use utf8 encoding, there will be no more garbled characters. Original article, please indicate that it is from Tengma PHP blog

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.
