Change the Chinese characters to \ x87 \ xE7 \ xA7 \ x91 \ xE7 \ x82 when inserting data in mysql.

Source: Internet
Author: User
When mysql inserts data, what is the Chinese character \ x87 \ xE7 \ xA7 \ x91 \ xE7 \ x82? The following test & nbsp; parameters are defined in the PHP file on the server, and are not transmitted on the client; $ sqlstr & nbsp; data is read by the adodb mssql database, and Chinese transcoding is read: iconv ("when mysql inserts data, is the Chinese character changed to \ x87 \ xE7 \ xA7 \ x91 \ xE7 \ x82?
The following test parameters are defined in the PHP file on the server and are not transmitted on the client;
$ Sqlstr data read by adodb mssql database, read Chinese Transcoding: iconv ("GBK", "UTF-8", $ str)

If you directly run the php file on the server, running mysql inert directly will not cause problems.

However, if a post is sent from the client to php, an error is returned when mysql is run:

Incorrect string value: '\ x87 \ xE7 \ xA7 \ x91 \ xE7 \ x82...' for column 'typename' at row 1

If echo $ sqlstr
Output: insert into dede_arctype SET id = '000000', reid = '000000', topid = '000000', sortrank = '50', typename = 'gynecological inflammatory ', typedir = '{cmspath}/A' no problem

Run directly on mysql-front:
Insert into dede_arctype SET id = '000000', reid = '000000', topid = '000000', sortrank = '50', typename = 'gynecological inflammatory ', no problem with typedir = '{cmspath}/'

Why ???
Mysql; share:
------ Solution --------------------
However, if a post is sent from the client to php, an error is returned when mysql is run:

Incorrect string value: '\ x87 \ xE7 \ xA7 \ x91 \ xE7 \ x82...' for column 'typename' at row 1


Convert the data you post to the encoding.

$typename = iconv("UTF-8", "UTF-8", $typename);


Try converting from UTF-8 to UTF-8
------ Solution --------------------
$ Db-> Execute ("set names UTF-8 ");???
This is the problem!
$ Db-> Execute ("set names UTF8 ");
Mysql indicates that the UTF-8 character set name is utf8, not UTF-8.
This special case is due to a programmer's mistake, but it cannot be corrected.
------ Solution --------------------
Implement urlencode ()-encoded URL string for form data transmitted from the client to the server

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.