When mysql inserts data, does the Chinese character change to x87xE7xA7x91xE7x82?

Source: Internet
Author: User
When mysql inserts data, does the Chinese character change to x87xE7xA7x91xE7x82? Mysql;

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 ???


Reply to discussion (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

Do not transcode
Echo base64_encode ($ str );
Post result

Do not transcode
Echo base64_encode ($ str );
Post result

Authorization/ljLvpmaLlpofnp5Hmi6XmnInkuIDmlK/authorization + a3seWcs + Wmh + enkSzkurrmtYEs55eb57uPLOeUn + authorization/lpofnp5En

Insert into dede_arctype SET id = '000000', reid = '0', topid = '0', sortrank = '0', typename = 'Hang Seng gynecology ', typedir = '{cmspath}/ahsfk', isdefault = '1', tempindex = '{style}/index_article.htm', templist =' {style}/list_article.htm ', temparticle = '{style}/article_article.htm', namerule =' {typedir}/{Y} {M} {D}/{aid1_.html ', namerule2 =' {typedir}/comment ', description = 'The Department of Gynecology of Hang Seng hospital is composed of multiple senior experts, attending physicians, and supervisors and nurses... ', keywords =' Shenzhen gynecology, abortion, dysmenorrhea, genital, cervical disease, female, inflammation, tumor, More... ', seotitle = 'Hang Seng gynecology'
No data problems
Do you have mysql_query ('set names utf8') before insertion?

Insert into dede_arctype SET id = '000000', reid = '0', topid = '0', sortrank = '0', typename = 'Hang Seng gynecology ', typedir = '{cmspath}/ahsfk', isdefault = '1', tempindex = '{style}/index_article.htm', templist =' {style}/list_article.htm ', temparticle = '{style}/article_article.htm', namerule =' {typedir}/{Y} {M} {D}/{aid1_.html ', namerule2 =' {typedir}/comment ', description = 'The Department of Gynecology of Hang Seng hospital is composed of multiple senior experts, attending physicians, and supervisors and nurses... ', keywords =' Shenzhen gynecology, abortion, dysmenorrhea, genital, cervical disease, female, inflammation, tumor, More... ', seotitle = 'Hang Seng gynecology'
No data problems
Do you have mysql_query ('set names utf8') before insertion?

$ Db-> Execute ("set names UTF-8 ");

Insert into dede_arctype SET id = '000000', reid = '0', topid = '0', sortrank = '0', typename = 'Hang Seng gynecology ', typedir = '{cmspath}/ahsfk', isdefault = '1', tempindex = '{style}/index_article.htm', templist =' {style}/list_article.htm ', temparticle = '{style}/article_article.htm', namerule =' {typedir}/{Y} {M} {D}/{aid1_.html ', namerule2 =' {typedir}/comment ', description = 'The Department of Gynecology of Hang Seng hospital is composed of multiple senior experts, attending physicians, and supervisors and nurses... ', keywords =' Shenzhen gynecology, abortion, dysmenorrhea, genital, cervical disease, female, inflammation, tumor, More... ', seotitle = 'Hang Seng gynecology'
No data problems
Do you have mysql_query ('set names utf8') before insertion?

$ Db-> Execute ("set names UTF-8 ");

Do not transcode
Echo base64_encode ($ str );
Post result

Eldest brother: insert Database Display: ­? Bytes®«Users ?... ?? Ç ?? Such gibberish,
If echo $ typename; is displayed: \ u4e0d \ u80b2 \ u4e0d \ u5b55' \ u6210 \ u529f
Why ???

$ 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.

Implement urlencode ()-encoded URL string for form data transmitted from the client to the server

Implement urlencode ()-encoded URL string for form data transmitted from the client to the server
The client does not transmit specific data, but only the operation conditions,

$ 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.

Thank you very much. It seems like this is a problem !!

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.