• Hello,

    after i’ve upgraded from wordpress 1.5 to 2.0, i’m getting this error message after my oldest post (at the very bottom):

    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 ” at line 1]
    SELECT COUNT(DISTINCT ID) FROM

    also, when i display posts in a category (or by a user or a month), i get the same message but it’s at the top.

    all posts are actually displayed correctly.

    i’m running:
    Apache/2.0.53 (Linux/SUSE)
    PHP/4.3.10
    MySQL 4.1.10a-log
    WP 2.0.2

    can you, please, help?

    thanks and have a nice day,

    =martin=

    ps. sorry, no link, the blog is behind a firewall.

Viewing 4 replies - 16 through 19 (of 19 total)
  • CamWheeler’s right (thanks!): I was unknowingly running a “hybrid” version of 1.5 and 2.x. What happened was that some of the 2.0.3 files had dates older than those on my FTP directory.

    If it helps anyone else I had the exact same problem and after reading CamWheeler’s reply I tried deleting and reuploading my files one at a time. When I uploaded “wp-blog-header.php” in the root folder the error went away. I guess that means it was something inside that file that was popping the error.

    I completely agree with Stevenw721; i recently noticed this error message at the bottom of my home page at the end of the very last post:
    “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 ” at line 1]
    SELECT COUNT(DISTINCT ID) FROM “

    All i had to do was replace the current “wp-blog-header.php” on my server with a fresh copy of the same file.
    I downloaded 2.05 and only grabbed this file and over wrote the file. In my case the file on my server was newer than the file I was uploading.
    Everything works very well again and I am able to see the link for previous postings.

    Well none of them didn’t work for me. So I edited template like this…
    I found the code piece(it varies from template to template):

    if ( !$max_page ) {
    if ( isset($max_num_pages) ) $max_page = $max_num_pages;
    else {
    preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
    $fromwhere = $matches[1];
    $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
    $max_page = $max_num_pages = ceil($numposts / $posts_per_page);
    }
    }..........

    and replaced it by

    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('« Previous Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Next Entries »') ?></div>
    </div>

    found in default wordpress template. Now pagination is working normally and there is no any more errors.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Database error after 1.5 -> 2.0 upgrade: SELECT COUNT(DISTINCT ID) FROM’ is closed to new replies.