When MySQL inserts data, does Chinese change \x87\xe7\xa7\x91\xe7\x82 this?
The following test parameters are defined on the server-side PHP file, and the client does not transmit;
$SQLSTR data read by ADODB MSSQL database, read the Chinese transcoding: Iconv ("GBK", "UTF-8", $str)
If you run the server-side PHP file directly, run MySQL inert without problems
However, if the client post to PHP, run MySQL error:
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 = ' 2001 ', Reid = ' 1002 ', topid = ' 1002 ', Sortrank = ' + ', TypeName = ' gynecological inflammation ', Typedir = ' {Cmsp ath}/a ' no problem.
Run directly on Mysql-front:
INSERT into dede_arctype SET id = ' 2001 ', Reid = ' 1002 ', topid = ' 1002 ', Sortrank = ' + ', TypeName = ' gynecological inflammation ', Typedir = ' {Cmspath }/a ' is no problem.
Why is this???
MySQL;
Share to:
------Solution--------------------
However, if the client post to PHP, run MySQL error:
Incorrect string value: ' \x87\xe7\xa7\x91\xe7\x82 ... ' for column ' TypeName ' at row 1
Convert the data you post to the code.
$typename = Iconv ("UTF-8", "UTF-8", $typename);
You try to switch from Utf-8 to Utf-8.
------Solution--------------------
$db->execute ("SET NAMES UTF-8");???
This is where the problem lies!
$db->execute ("SET NAMES UTF8");
MySQL indicates that the name of the utf-8 character set is UTF8 that's not utf-8.
This particular situation stems from the initial programmer's hand error, but can no longer be corrected.
------Solution--------------------
Implementation of the form data passed to the server by the client: UrlEncode () encoded URL string