WordPress.org

Ready to get started?Download WordPress

Forums

WordPress databass error after upgrading to v2.0 (8 posts)

  1. mezhopking
    Member
    Posted 8 years ago #

    Hi there, please check out http://www.hopkingdesign.com.

    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.

    Thanks,

    Mez

    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>
    <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="http://www.mezhopking.com/">www.mezhopking.com</a>.

    </div>
    <div id="photo">
    <h1>My Photos from Flickr and Beyond</h1>
    <div id="flickr">
    <script type="text/javascript" src="http://www.flickr.com/badge_code.gne?nsid=30946784@N00&amp;count=3&amp;display=latest&amp;name=0&amp;size=square&amp;raw=1"></script>
    <a href="http://www.flickr.com/photos/mez/"><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="http://www.mezhopking.com/"><img src="images/layout/mezhop-img.png" border="0" id="mezhopimg" title="See my photoblog at mezhopking.com" alt="See my photoblog at mezhopking.com" /></a>
    </div>
    </div>
    <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>
    <div id="links">
    <div class="navcontainer">
    <script type="text/javascript" src="http://del.icio.us/feeds/js/hopkingdesign?title=del.icio.us &raquo; Look what i found"></script>
    </div>
    </div>
    <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...

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

  2. MichaelH
    Member
    Posted 8 years ago #

    Very possible your wp-includes/comment-functions.php is corrupt. Delete that file and reupload it.

  3. mezhopking
    Member
    Posted 8 years ago #

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

  4. MichaelH
    Member
    Posted 8 years ago #

    Any plugins you can disable?

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

  5. mezhopking
    Member
    Posted 8 years ago #

    Thanks again, but still no joy.

  6. MichaelH
    Member
    Posted 8 years ago #

    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.

  7. mezhopking
    Member
    Posted 8 years ago #

    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.

  8. mezhopking
    Member
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic