Why does the insertion of database garbled characters occur after the local test is uploaded normally?

Source: Internet
Author: User
Why is the insertion of database garbled characters after the local test is uploaded normally? utf8 used in the front and back of php + SQL is used locally. everything is normal after the upload, but all the Chinese characters inserted into the database through the page are question marks? & lt; metahttp-equiv = & quot; Content-Type & quot; content = & quot
Php + SQL front and back use utf8 local everything is normal after uploading, reading is normal, but the Chinese characters inserted into the database through the page are all question marks. why?

Every page is configured

After each database connection
$ Dbh-> exec ("set character set utf8 ");
The encoding of the mysql database table and each field is utf8_generate_ci
All Chinese characters uploaded to the server normally are question marks.
Who can help me? I'm crying.

------ Solution --------------------
Mssql? Well, the encoding is correct. However, mysql is set names 'utf8', and I am not clear about mssql. This statement is not normal.
------ Solution --------------------
Discussion

Reference:
Mssql? Well, the encoding is correct. However, mysql is set names 'utf8', and I am not clear about mssql. This statement is not normal.
It's mysql exec ("set character set utf8"). This method is correct. I set the SET names 'utf8' and it's still useless.

------ Solution --------------------
Check whether the encoding format exported from the local database is all UTF-8, if yes, it is to see whether the exported Chinese content is question mark, and then imported to the server that the database encoding is not all UTF-8. the reason should be the format inconsistency. mysql should be used upstairs, and the statement should be mysql_query ("set names 'utf-8 '");
------ Solution --------------------
Add the following to the PHP page:
Header ('content-Type: text/html; charset = utf-8 ');
------ Solution --------------------
Or Niu Ge Huiyan, I wrote an error in front of it. it's utf8! On the phpadmin homepage, check whether MySQL connection verification is utf8_generate_ci.
The other is whether the Language is Chinese-Chinese simplified. if there is no problem, click export and check whether the character set of the file is utf8. if so, click the following execution, in this way, the data can be exported. if the data is imported, you must check whether the three items are consistent with those when you export them.

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.