Fixing unserialize() error at offset…

I’m working on an update to flickpress so it’s compatible with WP 3.3. I decided to upgrade to the latest version of phpFlickr, but started getting an error when browsing my favorites, something like this:
unserialize(): Error at offset 3400 of 8999

I tracked it down to a Japanese character in one of the photo titles and unserialize in phpFlickr. It was my fault though: the MySQL table that flickpress was installing didn’t specify a character set. I finally figured out that setting the table’s character set to UTF-8 would make unserialize happy. To do this with dbDelta, WordPress’ handy database table install/upgrade function, I changed my CREATE TABLE SQL to look like this:
CREATE TABLE table_name ( column1 CHAR( 35 ) NOT NULL ) DEFAULT CHARACTER SET UTF8;

To generalize, if you’re getting an unserialize error on data stored in a database, take a look at the table’s character set.

This entry was tagged . Bookmark the permalink. Share on Twitter or Facebook.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>