When mysql inserts a Chinese character, it cannot be inserted, and an exception occurs.

Source: Internet
Author: User
When mysql inserts Chinese characters, it cannot insert a prompt error & nbsp; MySQL returns: & nbsp; # 1366-Incorrectstringvalue: '\ xE4 \ xBD \ xA0 \ xE5 \ xA5 \ xBD' forcolumn 'strconnect 'atrow1. most of them are encoding problems. Mysql does not support this problem. if mysql inserts Chinese characters, it cannot be inserted and an error message is displayed.
Error
MySQL returns:

#1366-Incorrect string value: '\ xE4 \ xBD \ xA0 \ xE5 \ xA5 \ xBD' for column 'strconnect 'at row 1

------ Solution --------------------
Most of them are encoding problems. Mysql does not support such errors.

What is your database field type ??
------ Solution --------------------
Mysql, default character encoding test latin1, sometimes utf8, but still reports 1366.

The inserted string is utf8 encoded and the table is modified to utf8. the problem should be solved.
------ Solution --------------------
Mysql_query ("set names 'gbk'"); // This specifies the database character set, which is generally placed after the statement to connect to the database.




Single quotes 'specifies the character set to be converted'


------ Solution --------------------
Http://hi.baidu.com/fish124423/blog/item/3e301ab411a01ec636d3ca3b.html
Look at this. I fixed the problem according to the above!

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.