• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

Strange strings that cannot be inserted into a table

I'm collecting some random tweets.  For some of the tweets, I failed to insert their body into a MySQL database.  Following is the error message I received.

Incorrect string value: '\xF0\x9F\x91\xAF\xF0\x9F...' for column 'tweetBody' at row 1

Open in new window


Here is the tweet body.

Tell Tyga look for this chick called black china sill a nigga bitch ???? In a hot flash ?? menopause hot flash

Open in new window


I believe it's because of the squares.  The collation of the database is utf8 - default collation.

Thanks.
0
thomaszhwang
Asked:
thomaszhwang
2 Solutions
 
mrh14852Commented:
How are you escaping the text upon inserting?  Are you using mysql_real_escape_string() or similar?
0
 
johanntagleCommented:
What version of MySQL are you on?  What you are dealing with seem to be 4-byte UTF-8 characters.  Basically any version of MySQL before 5.5.3 cannot handle 4-byte utf-8 yet.  Possible solutions:

1.  Upgrade MySQL to 5.5.3
2.  Convert the fields to varbinary (http://dev.mysql.com/doc/refman/5.1/en/binary-varbinary.html)
0
 
thomaszhwangAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now