• For several weeks now, my rather large blog (1800+ posts, 20,000+ comments) has been returning this error whenever a comment is posted:
    WordPress database error: [Unknown column 'ID' in 'where clause']
    SELECT * FROM wp_comments WHERE ID = '21489'

    WordPress database error: [Unknown column 'ID' in 'where clause']
    UPDATE wp_comments SET comment_content = '' WHERE ID = '21489'

    The five-digit number is the comment ID (21489 in this case), but it should be the post ID (1835 in this case).

    I’ve done a lot of checking, and it looks like something is setting the value of the $ID variable to be the comment ID instead of the post id, but I can’t figure out what’s doing this. Or, perhaps it’s looking in the wp_comments table for the value of ID, whereas it should be looking in wp_posts (because there is no ID column in wp_comments).

    I have several sites running WordPress, and only one of them is doing this. All of the WP core files are the same, and I get the same error even if I switch themes or deactivate all my plugins, which leads me to believe it’s a database issue.

    The only difference between this database and those that work properly is that the “cardinality” of the comment_post_ID index in the wp_comments table is set to ‘none’ in the working DB, but is set to 1226 in the DB that’s giving an error. I tried dropping the index and re-creating it, but it shows up as 1226 again. I get the same error if I drop the index without re-creating it. So I’m not sure if this is it.

    To see the error, try leaving a comment on any post at my site. The comment is posted successfully, but the user sees an error message and has to hit back, which is annoying and obviously not as it should be.

    Your help is greatly appreciated

Viewing 5 replies - 1 through 5 (of 5 total)
  • What version of WordPress are you running? It looks like the version I have to work with and look at on my end (1.5.2) uses a different database setup. In the comments table, the id is called “comment_id”, not just “ID”. That makes it a little difficult to do any research. 🙂

    Thread Starter justinbaeder

    (@justinbaeder)

    I’m running 1.5.2 as well, and the ID vs. comment_id thing puzzles me as well. I’m wondering if something was altered by a plugin I used. Any ideas?

    Thread Starter justinbaeder

    (@justinbaeder)

    OK, I just installed a fresh copy of WordPress and ran the upgrade script, so I know it’s not a problem with any of the WordPress files. Must be something in the database – perhaps a table got renamed?

    I searched WP code and couldn’t find SQL similar to what you posted above. Could it have been a plugin?

    Thread Starter justinbaeder

    (@justinbaeder)

    Yes, it turned out to be the Scripturizer Remix plugin, which I have now deactivated. Thanks for going to the trouble of searching the code base!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp-comments-post.php gives error [Unknown column ‘ID’…], but comment is posted’ is closed to new replies.