SQLSTATE[HY000]: General error:1366 Incorrect String value

Source: Internet
Author: User
Tags drupal
SQLSTATE[HY000]: General error:1366 Incorrect string value: ' \xe4\xb8\x8a\xe5\xae\x98 ... ' for column ' content ' at row 1

Mysqld version:5.6
Character set to Utf-8

Later, based on this post: http://drupal.stackexchange.com/questions/88327/ Pdoexception-sqlstatehy000-general-error-1366-incorrect-string-value-wh
The suspicion is that the Utf-8 supported character set in MySQL is limited, so it's changed to UTF8MB4, but it doesn't solve the problem.

Help you heroes.

Reply content:

SQLSTATE[HY000]: General error:1366 Incorrect string value: ' \xe4\xb8\x8a\xe5\xae\x98 ... ' for column ' content ' at row 1

Mysqld version:5.6
Character set to Utf-8

Later, based on this post: http://drupal.stackexchange.com/questions/88327/ Pdoexception-sqlstatehy000-general-error-1366-incorrect-string-value-wh
The suspicion is that the Utf-8 supported character set in MySQL is limited, so it's changed to UTF8MB4, but it doesn't solve the problem.

Help you heroes.

Because the PDO is used, and the SQL statement is longer. The SQL statement was not posted.

The original PHP statement is: BookArticle::create(array('title' => $title, 'content' => $article_content, 'book_id' => $book->id, 'spider_url' => $url)); I use the laravel framework.

When executing the error:
SQLSTATE[HY000]: General error:1366 Incorrect string value: ' \xe4\xb8\x8a\xe5\xae\x98 ... ' for column ' content ' at row 1

I try to clean UTF8 code, still can't insert.

Then I just want to print out SQL and execute it in phpMyAdmin.

 $sql = "insert into book_articles set title='$title',content='$article_content',book_id=$book_id";

The error message in phpMyAdmin is data too long for text ...

Change the text to longtext problem solving.

Problem solved a bit slow for two reasons
The error message given in 1,PDO is not accurate enough.
2, there are several articles collected but there are coding problems, this problem is too interesting to attract attention.

Paste SQL (Word patch)

  • Related Article

    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.