[wp-hackers] wp_update_posts fails

Haluk Karamete halukkaramete at gmail.com
Tue Sep 18 01:27:15 UTC 2012

Hi, when I use the wp_update_post, from time to time I get a $post_id
0 indication of an error.

That's all due to the $post_content string containing some invalid
code, ( invalid as far as WP is concerned I guess ).

Anyway, I printed out the error; the error is

Incorrect string value: '\x92s own...' for column 'post_content' at row 1

I get the error thru

global $wpdb;
echo $wpdb->last_error;

And that's right after me detecting the wp_update_post returns 0.

how do you tackle such import problems  so that $content does not fail
the process like that!
Is there a way to clean the $content so that it becomes kosher enough
for the wp_update_post to go thru?

Content is all English. The culprit characters are those introduced by
our friends at Microsoft like the "stupid smart quotes" etc.
Since they may not be limited to smart-quotes, what universal solution
would you adopt?

Go thru the $content char by char and skip the ones that are not in
the proper ASCII range?

More information about the wp-hackers mailing list