WordPress.org

Ready to get started?Download WordPress

Forums

Database error; SQL syntax (5 posts)

  1. ceo
    Member
    Posted 6 years ago #

    Doing a search for this I couldn't find a specific thread that dealt with comments initiating this issue:

    WordPress 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 'AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15' at line 1 for query SELECT wp_comments.* FROM wp_comments WHERE comment_post_ID = AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15

    I do recall generating this error when I was using the OpenID plugin, but I gave up on that ages ago. I can't figure out what is causing the error because I personally can't seem to recreate it.

    Suggestions? I'm totally lost!

  2. Kafkaesqui

    Posted 6 years ago #

    When exactly does the error occur? And if it's displayed on an otherwise normally working page, where? No additional comment-related plugins such as one for recent comments?

    Looking over the SQL query the comment_post_ID is not being assigned a value (that is, the post's numeric ID). This is of course the cause of the error.

  3. ceo
    Member
    Posted 6 years ago #

    I can't figure out what triggers the error, Kaf, as I personally can't recreate it. I'm only seeing it pop up in error logs. And it's definitely not every comment.

    While it seems to have started randomly with all the plugins I had active working fine before this error cropped up, I did disable the two comment related ones I had (Absolute Comments - I think it was called, that allows you to comment through the admin panel - and Subscribe to Comments). As evidenced by the above post, that didn't seem to clear it up.

    Is it maybe being generated by spam comments?

  4. Kafkaesqui

    Posted 6 years ago #

    Hmm. Definitely strange if it's only appearing in your error log.

    Extremely unlikely it's due to spam attempts. It's a SELECT query, where something is making a request to the database for a number of comments (LIMIT 15) on a specific post. Or at least, it would be a specific post if the post ID was there.

    No chance any commented code is hiding in your templates or perhaps a function in the theme's functions.php? Long shot guess as I'm not sure what the need would be (in a plugin or some embedded code) for calling the comments on a post, but limiting them to just 15.

  5. ceo
    Member
    Posted 6 years ago #

    Well, hmm.

    I did move to a new domain and server, but I moved the entire website, databases and all . . . so I can't say it's that. And I haven't changed any of my theme files, etc. even when I was using comment related plugins.

    I only suggested that perhaps it's a spam thing because I'm not seeing a comment pop up necessarily when I notice the error times in my log. But I've personally left comments and other people have as well and there's no SQL error generated. I'm totally befuddled.

    It's so random and weird, it's nearly funny. The 15 thing I really don't get . . . coincidently though that is how many posts are pulled for each PAGE of posts on my site, but I hardly think that's related.

Topic Closed

This topic has been closed to new replies.

About this Topic