Store Chinese characters in the CI framework and report a database error. Code: $ comDataarray (& #039; textArea & #039; & amp; gt; $ textArea, & #039; commentID & #039; & amp; gt; $ newComID, & #039; postID & #039; & amp; gt; $ newPostID,); $ this-& amp; gt; db-& amp; gt; insert (& #039; COMMENTMETA & #039;, $ comData );...
Saving Chinese characters in the CI framework reports database errors
This is the code: $ comData = array ('textarea '=> $ textArea, 'commentid' => $ newComID, 'postid' => $ newPostID ,); $ this-> db-> insert ('commentmeta', $ comData); the following Error message is displayed: Error Number: 1366
Incorrect string value: '\ xE6 \ xB5 \ x8B \ xE8 \ xAF \ x95' for column 'textarea 'at row 1
INSERTCOMMENTMETA(textArea,commentID,postID) VALUES ('test', 8, 28)
Filename: F: \ code \ CI \ system \ database \ DB_driver.php
Line Number: 330
Database encoding: Mysql encoding is utf8
Reply content:
Saving Chinese characters in the CI framework reports database errors
This is the code: $ comData = array ('textarea '=> $ textArea, 'commentid' => $ newComID, 'postid' => $ newPostID ,); $ this-> db-> insert ('commentmeta', $ comData); the following Error message is displayed: Error Number: 1366
Incorrect string value: '\ xE6 \ xB5 \ x8B \ xE8 \ xAF \ x95' for column 'textarea 'at row 1
INSERTCOMMENTMETA(textArea,commentID,postID) VALUES ('test', 8, 28)
Filename: F: \ code \ CI \ system \ database \ DB_driver.php
Line Number: 330
Database encoding: Mysql encoding is utf8
Check whether the following table is UTF-8. This is an optional attribute when you create a new table.
Update:
I have carefully read that your model does not seem to comply with CI specifications and uses arrays. Which of the following statements is true:
$ This-> [key name] = $ this-> input-> post ('***');
In addition, you can check the configuration file in the folder of the corresponding library in the mysql data folder, which must be UTF-8.
Your description only indicates that your mysql environment is utf8 and does not indicate that the table you inserted and the fields are also UTF-8 encoded. In addition, check whether the encoding of your file (or the encoding of the inserted data) is utf8.
Useiconv()Convert the encoding of the inserted string
See the database-related CI manual.
Check this row $ db ['default'] ['Char _ set'] = "utf8 ";