Support » Fixing WordPress » WordPress databass error after upgrading to v2.0

  • Hi there, please check out

    This error only occurs on the index.php page of my site.

    This page used to work perfectly before I upgraded to version 2 of WordPress. If this can’t be resolved soon, I’m going to have to revert to version 1.5 again.

    Below I’ve included the WordPress error I recieve and my index.php code.

    Any help on this issue will be very very welcome.



    This is the error I get:
    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” at line 1]
    SELECT COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = AND comment_approved = ‘1’;

    This is my index.php code:

    <?php get_header(); ?>
    <body id="home">
    <div id="background">
    <div id="page">
    <?php include "logo.php"; ?>
    <div id="splash">
    <div id="content">
    <div id="welcome">
    <h1>Hello and welcome</h1>
    <h2>We are Hopking Design</h2>
    Hopking Design is a one man creative studio run by Mez Hopking, a freelance web designer, graphic designer and professional photographer, based in Bournemouth, England.

    I specialise in building intuitively made, well laid out and logically structured XHTML and CSS standards compliant web sites. I also design for print, in particular logo design, t-shirt design and re-branding. Please head on over to my <a href="portfolio.php?page=welcome">portfolio</a> to view some examples of my work. Alternatively, to view my photography portfolio please head on over to <a href=""></a>.

    <div id="photo">
    <h1>My Photos from Flickr and Beyond</h1>
    <div id="flickr">
    <script type="text/javascript" src=";count=3&amp;display=latest&amp;name=0&amp;size=square&amp;raw=1"></script>
    <a href=""><img src="images/layout/flickr-img.png" border="0" id="flickrimg" title="See more of my Flick feed" alt="See more of my Flick feed" /></a>
    <a href=""><img src="images/layout/mezhop-img.png" border="0" id="mezhopimg" title="See my photoblog at" alt="See my photoblog at" /></a>
    <div id="post">
    <h1>Latest Journal Entry</h1>
    <?php $posts = get_posts('numberposts=1&order=DESC&orderby=post_title'); foreach ($posts as $post) : start_wp(); ?>
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php the_date(); echo ""; ?>

    <?php the_excerpt(); ?>
    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Continue Reading...</a></h3>
    <?php endforeach; ?>
    <p class="comment"><?php edit_post_link('Edit','','|'); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »','','|'); ?> <?php next_posts_link('&laquo; Previous Entries','','|') ?> <?php previous_posts_link('Next Entries &raquo;' ,'','|') ?><a href="feed:<?php bloginfo('rss2_url'); ?>">RSS Feed</a>

    <div id="links">
    <div class="navcontainer">
    <script type="text/javascript" src=" &raquo; Look what i found"></script>
    <div id="shop">
    <h1>Shop and Downloads</h1>
    <h2>The real french connection</h2>
    <img src="images/shop-fr-tshirts.png" alt="Real French connection T-shirts. Visit my shop for more..." title="Real French connection T-shirts. Visit my shop for more..." />
    Inspired by a recent trip to Paris, I've designed these rather lovely t-shirts. Choose which French iconic image you'd like wear with pride...

    <?php include "footer.php"; ?>

Viewing 7 replies - 1 through 7 (of 7 total)
  • Very possible your wp-includes/comment-functions.php is corrupt. Delete that file and reupload it.

    Hi MichaelH, I’m affraid that solution doesn’t work.
    Thanks anyway though, any other ideas?

    Any plugins you can disable?

    Also first try to delete wp-contents/cache folder.

    Thanks again, but still no joy.

    I keep thinking you have a problem with your comments-function.php file.

    The error you see has this:
    SELECT COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = AND comment_approved = '1';

    And my comments-function.php has this:
    $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");

    So check your comments-function.php file in the area of the function comments_popup_link agrees with what my file shows.

    There isn’t a problem with my comment-function.php file. There must be a problem with my code on index.php… but I can’t see what it is. Strange that it worked perfectly with 1.5 but not with 2.0.

    Any ideas?

    Thanks again.

    Just to let you know that I’ve given up trying to fix this problem and I’ve reverted to using version 1.5, which works perfectly. Version 2.0’s backend did look and feel better, but I’m not willing to invest countless hours trying to repair something that wasn’t broken.

    Thanks again for your help in trying to resolve my problem.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WordPress databass error after upgrading to v2.0’ is closed to new replies.