Php solves the problem of Incorrectstringvalue: amp; # x27; xF0x9Fx92x8BTi when inserting MySQL data... amp; # x27; error when inserting data into MySQL in the project, it is found that the data insertion is incomplete. through debugging, it is found that there are no special errors in the insert statement. However, if the difference does not exist, debug the mysqli error.
$ Ret = mysqli_query ($ this-> conn, $ SQL) or die (mysqli_error ($ this-> conn ));
The following error message is displayed:
Incorrect string value: '/xF0/x9F/x92/x8BTi ...'
If there is an error message, you can check the result online. The result is that the mysql encoding format is UTF-8, and four-byte string insertion is not supported.
There are two methods available on the Internet:
1. upgrade MySQL and change the corresponding data type to utf8mb4.
2. the four-byte UTF-8 character appears to filter or convert to custom type
Because MySQL 5.1 is installed, Method 1 is not suitable. I chose the second filter string to convert it into a suitable 3-byte UTF-8
$ Str = preg_replace ('/[/x {10000}-/x {10 FFFF}]/U', '', $ str );
Although it still cannot be solved perfectly, at least ensure that each piece of data can be correctly inserted!
If you want to solve the problem perfectly, you 'd better upgrade MySql and change the data type to utf8mb4.