The loss of mysql storage Chinese characters in IE is so strange in the world.

Source: Internet
Author: User
The loss of mysql storage in IE is so strange in the world. First of all, my database and page use UTF-8 encoding. the page code is as follows:

Header ("Content-type: text/html; charset = utf8 ");
$ Result = $ mysqli-> query ("select * from 'com _ class' where 'id' =". $ _ GET ['id']);
If (! ($ Result-> fetch_row ())){
Echo "data does not exist ";
Exit;
}
$ Mysqli-> query ("update 'com _ class' set 'name' = '". $ _ GET ["name"]. "'where'id' = ". $ _ GET ['id']);
Echo $ _ GET ['name'];

In Google and Firefox, the page is normally displayed without garbled characters, and the data is stored in the database.

In IE9, the page is displayed as normal, no error is reported, no garbled code is displayed, but the database does not store data, and the display is blank (not "?" If $ _ GET ['name'] is in English, the database can be stored normally.

Let's talk about what's going on. I still can understand that the browser needs to be taken care of at the front end. does this storage database still take care of different browsers?


Reply to discussion (solution)

Update 'com _ class' set 'name' = '". $ _ GET ["name"]. "'where'id' = ". $ _ GET ['id'] is this statement successfully executed in the database?

Update 'com _ class' set 'name' = '". $ _ GET ["name"]. "'where'id' = ". $ _ GET ['id'] is this statement successfully executed in the database?



If Google and Firefox can be properly stored in the database, it means the execution is successful.


Update 'com _ class' set 'name' = '". $ _ GET ["name"]. "'where'id' = ". $ _ GET ['id'] is this statement successfully executed in the database?



If Google and Firefox can be properly stored in the database, it means the execution is successful.


Print $ mysqli-> error.



Update 'com _ class' set 'name' = '". $ _ GET ["name"]. "'where'id' = ". $ _ GET ['id'] is this statement successfully executed in the database?



If Google and Firefox can be properly stored in the database, it means the execution is successful.


Print $ mysqli-> error.



I tried it. No problem

In IE, English can be normally stored in the database, and only Chinese characters will be lost. I think it should be a problem with SQL statements. it should be something wrong with coding, but I clearly know that the database and PHP pages are all UTF-8 encoded, so it should be normal.

No code for database connection and character set settings
As a test, you should print the input data

No code for database connection and character set settings
As a test, you should print the input data



These codes are included in the reference file. I did not write them here. The problem now is that the data can be stored successfully in other browsers, which means the connection and SQL are certainly OK, don't you think so.

I still want to answer this question if I have a master or have encountered such a problem.

No code for database connection and character set settings
As a test, you should print the input data



Only $ _ GET ["id"] and $ _ GET ["name"]

So what is the imported data, is it also "referenced?
If you really want to solve the problem, you 'd better provide as much information as possible.

No code for database connection and character set settings
As a test, you should print the input data



$ Host = "localhost ";
$ User = "root ";
$ Password = "";
$ Datebase = "company ";
$ Mysqli = new mysqli ("$ host", "$ user", "$ password", "$ datebase ");
/* Check the connection */
If (mysqli_connect_errno ()){
Printf ("connection failed: % s \ n", mysqli_connect_error ());
Exit ();
}
$ Mysqli-> set_charset ("utf8 ");

This is the code used to connect to the database and set the character set. it is included in another file.

The difference between IE and other browsers is that it strictly complies with the rules.
This is also the reason for the previous anti-monopoly attacks.

So what is the imported data, is it also "referenced?
If you really want to solve the problem, you 'd better provide as much information as possible.



Except the two GET statements, no data is input. in the address bar, enter: http: // localhost/update. php? Id = 1 & name = Michael Jacob. google and Firefox can store Michael Jacob in the database. no error message is displayed on the IE9 page, that is, no data is stored in the database, including the original data is gone, just a blank character

The difference between IE and other browsers is that it strictly complies with the rules.
This is also the reason for the previous anti-monopoly attacks.



However, it should be okay to store data with the client browser. these are all executed in MYSQL.

This is not surprising because it is IE.

Find the reason. IE9 does not recognize Chinese characters in the address bar. use encodeURI to encode the input data.

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.