Encoding problem occurs when Mysql stores Chinese characters in the CI framework

Source: Internet
Author: User
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 ";

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.