Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

php - ERROR 1366 (HY000): Incorrect string value: 'xF0x9Fx98x9C' for column 'comment' at row 1

Here's my sql:

INSERT INTO comments (createdate,userid,profileid,comment,status) 
VALUES (1449503167,65704,65704,'@Mr_S66 Wish I was There For The Xmas Party I Miss My Studio 66 Family e???',15)

Here's my comments schema:

    +------------+---------------+------+-----+---------+----------------+
    | Field      | Type          | Null | Key | Default | Extra          |
    +------------+---------------+------+-----+---------+----------------+
    | commentid  | int(11)       | NO   | PRI | NULL    | auto_increment |
    | parentid   | int(11)       | YES  |     | 0       |                |
    | refno      | int(11)       | YES  |     | 0       |                |
    | createdate | int(11)       | YES  |     | 0       |                |
    | remoteip   | varchar(80)   | YES  |     |         |                |
    | locid      | int(11)       | YES  | MUL | 0       |                |
    | clubid     | int(11)       | YES  |     | 0       |                |
    | profileid  | int(11)       | YES  | MUL | 0       |                |
    | userid     | int(11)       | YES  | MUL | 0       |                |
    | legacyuser | int(11)       | YES  | MUL | 0       |                |
    | mediaid    | int(11)       | YES  |     | 0       |                |
    | status     | int(11)       | YES  |     | 1       |                |
    | comment    | varchar(4000) | YES  |     |         |                |
    | likes      | int(11)       | YES  |     | 0       |                |
    | dislikes   | int(11)       | YES  |     | 0       |                |
    | import     | int(11)       | YES  |     | 0       |                |
    | author     | varchar(50)   | YES  |     |         |                |
    +------------+---------------+------+-----+---------+----------------+

Heres my output of the sql query:

ERROR 1366 (HY000): Incorrect string value: 'xF0x9Fx98x9C' for column 'comment' at row 1

Not quite sure how to solve this yet. Possibly filter the comment text using php to accommodate the string value.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Something in your environment is not set up to correctly process Unicode text.

The byte sequence F0 9F 98 9C, represented incorrectly as "e???" in your query, is the UTF8 encoding of the Unicode character "??", FACE WITH STUCK-OUT TONGUE AND WINKING EYE. (That is, it's an emoji character.)

To store this character correctly, you will need to make sure that:

  • You are enabling UTF8 on your MySQL connection (i.e, SET NAMES utf8mb4, or use an option when connecting that similarly enables it).
  • You are running MySQL 5.5 or later.
  • Your table's character set is utf8mb4.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...