Title: Database error in post preview.
Last modified: August 18, 2016

---

# Database error in post preview.

 *  [notryan](https://wordpress.org/support/users/notryan/)
 * (@notryan)
 * [21 years, 8 months ago](https://wordpress.org/support/topic/database-error-in-post-preview/)
 * My blog looks fine and the post content is fine except I noticed that when going
   to “Edit” on a post an seeing the post preview at the bottom I get an error above
   the post:
    Database error: [You have an error in your SQL syntax. Check the manual
   that corresponds to your MySQL server version for the right syntax to use near”
   at line 1] SELECT post_content FROM wp_posts WHERE id= This doesn’t really affect
   the blog, but it just annoys me when there’s an error on the site. 😛 Can anybody
   help me find the source of this problem and/or how to fix it? Thanks! -Ryan

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [planetthoughtful](https://wordpress.org/support/users/planetthoughtful/)
 * (@planetthoughtful)
 * [21 years, 8 months ago](https://wordpress.org/support/topic/database-error-in-post-preview/#post-103676)
 * Hi Ryan,
    At a quick guess I’d suggest it’s a plugin you have that isn’t being
   supplied a variable it expects in an SQL string when on the edit page, but is
   when the posts are being viewed. First step is to diagnose which plugin, if that
   is the problem. Deactivate, one by one, each of your active plugins, and see 
   if the error message disappears. If it disappears when a particular plugin is
   deactivated, we’re closer to working out how to fix the problem in particular.
   Let us know how you go. Much warmth, planetthoughtful
 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [21 years, 8 months ago](https://wordpress.org/support/topic/database-error-in-post-preview/#post-103699)
 * It’s the word/image count plugin.
    I noticed this a few days ago and with some
   help here from Mark Jacquith, tracked it down. It’s the plugin by Chuck G. I 
   mailed him and his fix is below: “Around line 102, you should see: add_filter(‘
   the_content’, ‘add_post_counts’); Change this to: if (!strpos($_SERVER[‘SCRIPT_NAME’],“/
   wp-admin/”)) { add_filter(‘the_content’, ‘add_post_counts’); } All this is doing
   is forcing the plugin not to run, or be applied when you’re looking a the site
   through the admin panel.” Works just fine 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Database error in post preview.’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Mark (podz)](https://wordpress.org/support/users/podz/)
 * Last activity: [21 years, 8 months ago](https://wordpress.org/support/topic/database-error-in-post-preview/#post-103699)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
