Incorrect string value: ‘\x99 is y…’ for column

If you receive this error from MySQL when inserting text in your column or some other similar error as:

Incorrect string value: ‘\xC2\x99 is …’ for column

then it most likely has something to do with the characters that are attempted to be inserted.

View these MySQL postings:

One workaround is to create external files with these characters and use the PHP function ob_get_contents().

The other solution is to create a small function that will parse (i.e. strip) the contents containing illegitimate characters using eregi_replace() or str_replace() functions. Then when extracting it replace those characters as it’s displayed. It’s workaround. I believe it’s a bug and it’s a hindrance but will work.

Before inserting the contents to the column if you know the “offending” characters that MySQL database is rejecting then simply replace those characters with {offending characters} and then use insert the contents. When selecting the contents and displaying it to your browser use the eregi_replace() function of PHP.

Thirdly, the option that I’m using currently is use the functions htmlentities() or htmlspecialcharacters(). This seems to be the easiest solution for now. I hope this helps someone.

Share and Enjoy:
  • Digg
  • Sphinn
  • Facebook
  • Mixx
  • Google Bookmarks
  • Share

You must be logged in to post a comment.