PHP is not garbled, and the database background is garbled

Source: Internet
Author: User
Tags toad for mysql
PHP is not garbled. the database background garbled text Post was last edited by susoft2008 at 18:05:28

Database garbled database PHP garbled

PHP addition, modification, and query are not garbled. 1,
Garbled characters are displayed on the backend of the MySQL database,
Why?

:


:


Reply to discussion (solution)

What software is used to view garbled characters?

Great Gods, solve it.

What software is used to view garbled characters?
Toad For MySQL

PS: The cvs files are garbled everywhere, Chinese ....

The link verification for your database fields is the default latin1
The data you saved is UTF-8
You have not declared the required character set for mysql, so mysql still extracts data from latin1. It's UTF-8 for you.

However, the mysql management tool declares the required character set, so garbled characters occur when it is converted to utf8 as latin1.

PHP addition, modification, and query are not garbled. 1,
Garbled characters are displayed on the backend of the MySQL database,
Why?

:


:


PS:
Page code use UTF-8


Database table encoding using UTF-8

The link verification for your database fields is the default latin1
The data you saved is UTF-8
You have not declared the required character set for mysql, so mysql still extracts data from latin1. It's UTF-8 for you.

However, the mysql management tool declares the required character set, so garbled characters occur when it is converted to utf8 as latin1.

The verification code is utf8_general_ci.

That's right. latin1 should be unable to insert UTF-8 data. I was still thinking about how you inserted the data.
However, this does not affect my explanation, but it is just a step ahead of schedule.
The default character set of mysql is latin1, and few users change the default character set when installing mysql (most people do not know where to modify it ).
Therefore, as long as the non-default character set is used to operate mysql, the set names character set code must be executed before the operation.
For UTF-8, set names utf8
Save the following code in UTF-8 encoding and run it.

 Or save the following code in gbk encoding and then run it.
  You will see this result

Make sure that the three points are consistent and there will be no garbled characters:
1. database and data table encoding
2. page internal code
3. file encoding

That's right. latin1 should be unable to insert UTF-8 data. I was still thinking about how you inserted the data.
However, this does not affect my explanation, but it is just a step ahead of schedule.
The default character set of mysql is latin1, and few users change the default character set when installing mysql (most people do not know where to modify it ).
Therefore, as long as the non-default character set is used to operate mysql, the set names character set code must be executed before the operation.
For UTF-8, set names utf8
Save the following code in UTF-8 encoding and run it.

   Or save the following code in gbk encoding and then run it.
    You will see this result



I can't understand it. I still don't know where the problem is? The database code should be UTP8: "show variables like 'character _ set_database ';" --- "UTF8 @~~~~~~~~~~~

The key is the character_set_server value.

If the code is garbled, find the encoding.

The key is the character_set_server value.

How do I view the character_set_server value when the application is released on the purchased virtual host?

The key is the character_set_server value.
Thank you for your advice.

Show variables like 'character _ set_server'

Show variables like 'character _ set_server'

The result is a UTF-8

A little unreasonable. the last trick
Select BINARY supplier _ from tbl_name where id _ = 17

Echo base64_encode ('Retrieved data ');
Post result

A little unreasonable. the last trick
Select BINARY supplier _ from tbl_name where id _ = 17

Echo base64_encode ('Retrieved data ');
Post result

Result example (the result is the result of the database client, and the PHP page data is displayed normally ):
PS: The two pictures in the topic content of this post are PHP pages, which are displayed normally. for database clients, garbled code is displayed, and cvs is also garbled everywhere.



What do you use for textures?
I want you to use the program to retrieve the garbled content and paste its base64 encoded value
This will help you analyze

Besides, when you paste garbled text, you should also paste the content that is not messy.

What do you use for textures?
I want you to use the program to retrieve the garbled content and paste its base64 encoded value
This will help you analyze

Thank you, boss.

Besides, when you paste garbled text, you should also paste the content that is not messy.

No garbled content:


Garbled content after BINARY:

I want your results like this
Echo base64_encode ($ t); // w6fCscK7w6fCm8Kuw6XCm8Kb
$ T refers to the garbled fields read in BINARY format.

By image comparison (#7), you are still using the UTF-8 format processed by latin1.
Do you insert the data before modifying the character set?

I want your results like this
Echo base64_encode ($ t); // w6fCscK7w6fCm8Kuw6XCm8Kb
$ T refers to the garbled fields read in BINARY format.

By image comparison (#7), you are still using the UTF-8 format processed by latin1.
Do you insert the data before modifying the character set?

No .. The character set has not been changed. the supplier said it cannot be changed. it should be because the database code was not set to utf8before insertion.
+ QQ: 252613934
Leave QQ to discuss

I want your results like this
Echo base64_encode ($ t); // w6fCscK7w6fCm8Kuw6XCm8Kb
$ T refers to the garbled fields read in BINARY format.

By image comparison (#7), you are still using the UTF-8 format processed by latin1.
Do you insert the data before modifying the character set?

3Q

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.