Support » Fixing WordPress » Comment error: “Unknown colum ‘ID’ in ‘where clause’

  • Every time a comment is left on my site, the user gets an error that says:
    WordPress database error: [Unknown column 'ID' in 'where clause']
    SELECT * FROM wp_comments WHERE ID = '25161'

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

    To see for yourself, leave a comment here.

    The comment goes through OK, but the user has to hit “back” and refresh the page to see his/her comment. Very annoying. I’ve posted on this here and here, but I still don’t know the source of the problem or how to fix it.

    I’ve upgraded to wp2.0, replacing all of my core WP files, and I’ve tried other themes (including Kubrick), so I know it’s not a problem with any of the WP core files or my theme. It must be a database problem, but I’m not sure what to make of the database – everything looks the same as my sites that are working.

    So here’s my question: What line of what file is generating the query that throws this error? The address bar says I’m in wp-comments-post.php when the error is displayed, so that’s my best guess. wp-comments-post.php contains this line:
    $status = $wpdb->get_row("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'");

    If I’m understanding correctly, this is fetching the comment status and post status from the wp_posts table in the database, to determine which message to display (e.g. “your comment is in moderation,” etc.) upon returning the user to the individual archive page. However, this doesn’t happen because of the error.

    If that’s not the code that’s generating the error, what else could it be?

    If that is the code, what’s wrong with my database?

    By the way, if I use PHPMyAdmin to run this query manually:
    SELECT * FROM wp_comments WHERE ID = '25161'
    I don’t get an error – it returns the data it’s supposed to.

    Any suggestions would be greatly appreciated. Let me know if it would help to provide other info about my database or anything else. Thanks.

Viewing 1 replies (of 1 total)
  • Problem solved, thanks to d0ngle: The plugin Scripturizer Remix is to blame for this error. Deactivating it caused the error to vanish.

Viewing 1 replies (of 1 total)
  • The topic ‘Comment error: “Unknown colum ‘ID’ in ‘where clause’’ is closed to new replies.