PHP is not garbled, database background garbled

Source: Internet
Author: User
This post was last edited by susoft2008 on 2013-07-22 18:05:28

Database garbled database PHP garbled

PHP additions, modifications, queries are not garbled, 1,
MySQL Database backend display garbled, 2,
What's the reason?

Figure 1:


Figure 2:


Reply to discussion (solution)

What software is used to see the garbled

Great gods, solve them.

What software is used to see the garbled
Toad for MySQL

PS: CVS files Everywhere are garbled, Chinese ah ....

The connection proofing of your database fields is the default latin1
The data you deposited is utf-8.
You do not have the required character set for MySQL declaration, so MySQL still latin1 out the data. For you, it's utf-8.

However, the MySQL management tool is to declare the required character set, so as latin1 UTF8 converted to UTF8 when there is garbled phenomenon

PHP additions, modifications, queries are not garbled, 1,
MySQL Database backend display garbled, 2,
What's the reason?

Figure 1:


Figure 2:


Ps:
Page encoding using UTF-8


database table encoding using UTF-8

The connection proofing of your database fields is the default latin1
The data you deposited is utf-8.
You do not have the required character set for MySQL declaration, so MySQL still latin1 out the data. For you, it's utf-8.

However, the MySQL management tool is to declare the required character set, so as latin1 UTF8 converted to UTF8 when there is garbled phenomenon

The proofreading code is: utf8_general_ci

That's right, if it is latin1 should be plugged in utf-8 data. When I replied, I was thinking, how did you get the data into it?
But it doesn't affect the explanation I gave, it's just a step forward.
MySQL's default character set is Latin1, and few people change the default character set when installing MySQL (most do not know where to modify it).
So whenever a non-default character set operation is used, MySQL must execute the Set names character set code before operation
For Utf-8 is set names UTF8
Save the following code in Utf-8 encoding, and then run

 or save the following code in GBK encoding, and then run
  You'll see the result.

Ensure that the 3-point consistency will not garbled:
1, Database and data table encoding
2. Internal code of the page
3, the file encoding

That's right, if it is latin1 should be plugged in utf-8 data. When I replied, I was thinking, how did you get the data into it?
But it doesn't affect the explanation I gave, it's just a step forward.
MySQL's default character set is Latin1, and few people change the default character set when installing MySQL (most do not know where to modify it).
So whenever a non-default character set operation is used, MySQL must execute the Set names character set code before operation
For Utf-8 is set names UTF8
Save the following code in Utf-8 encoding, and then run

   or save the following code in GBK encoding, and then run
    You'll see the result.



A little understanding, or do not know where the problem is? The database encoding should be UTP8: "Show variables like ' character_set_database ';" ---"Return to utf8@~~~~~~~~~~~

The key is the value of Character_set_server.

If it's garbled, go find the code.

The key is the value of Character_set_server.

When the app is published on a purchased virtual host, how do I see the value of the Character_set_server?

The key is the value of Character_set_server.
Thanks for pointing.

Show variables like ' Character_set_server '

Show variables like ' Character_set_server '

The result is UTF-8.

It's a little unreasonable, the last trick.
Select BINARY supplier_ from Tbl_name where id_=17

echo Base64_encode (' data taken out ');
Post the results

It's a little unreasonable, the last trick.
Select BINARY supplier_ from Tbl_name where id_=17

echo Base64_encode (' data taken out ');
Post the results

As a result (the result is the result of the database client, the PHP page data is displayed as normal):
PS: The 2 images in the topic of this post--"Figure 1 is a PHP page, the display is normal; Figure 2 is a database client, showing garbled, CVS is garbled everywhere



What's your use for stickers?
I want you to use the program to remove the garbled content, and post its base64 encoded value
This will help you analyze it.

Besides, if you put out garbled characters, you should also post the content that is not messy.

What's your use for stickers?
I want you to use the program to remove the garbled content, and post its base64 encoded value
This will help you analyze it.

Understand, like, thank you, boss.

Besides, if you put out garbled characters, you should also post the content that is not messy.

No garbled content:


Garbled content after using binary:

I want you to get a result like this.
echo Base64_encode ($t);//w6fcsck7w6fcm8kuw6xcm8kb
$t is the contents of a garbled field that is read by binary (binary) mode

by graphic comparison (#7 method) you're still being treated as a latin1 utf-8.
Is this data inserted before you modify the character set?

I want you to get a result like this.
echo Base64_encode ($t);//w6fcsck7w6fcm8kuw6xcm8kb
$t is the contents of a garbled field that is read by binary (binary) mode

by graphic comparison (#7 method) you're still being treated as a latin1 utf-8.
Is this data inserted before you modify the character set?

No, it's not. The character set did not change, the supplier said it could not be changed, should be inserted before the database encoding for UTF8.
+qq:252613934
Leave QQ to discuss

I want you to get a result like this.
echo Base64_encode ($t);//w6fcsck7w6fcm8kuw6xcm8kb
$t is the contents of a garbled field that is read by binary (binary) mode

by graphic comparison (#7 method) you're still being treated as a latin1 utf-8.
Is this data inserted before you modify 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.