• 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 15 replies - 1 through 15 (of 19 total)
  • Did you run /wp-admin/upgrade.php ? The database structure has changed since 1.5.

    I have this error also.
    I ran upgrade.php.

    my blog is viewable at http://www.webdevireland.com/blog/

    Thread Starter tropos

    (@tropos)

    filosofo: yes, i ran upgrade.php right after i upgraded to 2.0.

    For those of you who are getting this problem, did you replace the 1.5 .htaccess file with the 2.0 one? In other words, are you using the internal permalinks rewriting system?

    Thread Starter tropos

    (@tropos)

    filosofo: in 1.5 i was using the “almost pretty” permalinks (without mod_rewrite). i’ve just found out that when i upgraded to 2.0, it was automatically switched to default with the parameter (?p=123), but now i switched back to the original “almost pretty” permalinks (/index.php/%year%/%monthnum%/%day%/%postname%/). i’m still getting the same error message.

    So you were getting the error even with the default permalinks setting (in other words, when your links were all like /?p=123)?

    Is this a Windows or Unix/Linux server?

    To help diagnose the problem, copy the dump environment plugin to a file such as dump_env.php (Make sure there are no spaces before the first <?php or after the last ?>. Then change the third line of the plugin from $hide = true; to $hide = false;

    Put it in your plugins directory, and activate it.

    Then at the bottom of your WordPress posts and pages there is a lot of interesting data. On the pages that produce the error, I’d like to know the first block of stuff immediately after “Environment Dump,” such as REQUEST_URI, QUERY_STRING, FILE, WP Query String, and WP Query Query String.

    Also, under the heading “WP_Query” you should see something like
    wp_query Object
    (
    [request] => SELECT . . .

    I’d like to know what that [request] is on your error pages.

    HOME: http://www.webdevireland.com/blog
    SITEURL: http://www.webdevireland.com/blog/wordpress
    PERMA STRUCTURE: /%year%/%monthnum%/%day%/%postname%/
    PATH INFO:
    REQUEST_URI: /blog/
    QUERY_STRING:
    SCRIPT_NAME: /blog/index.php
    SCRIPT_FILENAME: /home/user1/domains/webdevireland.com/public_html/blog/index.php
    PHP_SELF: /blog/index.php
    ERROR:
    FILE: /home/user1/domains/webdevireland.com/public_html/blog/wordpress/wp-content/plugins/dump_env.php
    WP Query String:
    WP_Query Query String:

    wp_query Object
    (
    [request] => SELECT DISTINCT * FROM blog_posts WHERE 1=1 AND post_date_gmt <= ‘2006-05-22 22:36:59’ AND (post_status = “publish” OR post_author = 1 AND post_status != ‘draft’ AND post_status != ‘static’) AND post_status != “attachment” GROUP BY blog_posts.ID ORDER BY post_date DESC LIMIT 0, 10

    This error appears to happen when archive.php in the kubrick theme calls

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

    next_posts_link() seems to be where it falls over.

    Appreciate any help you can give me filosofo.

    evilhomer, I don’t know what’s going wrong. As I understand the error message you’re getting, it’s saying that there’s nothing in [request] between SELECT DISTINCT * FROM and ORDER BY, but we can see that there’s stuff there.

    In the file wp-includes/template-functions-links.php, does the first part of the next_posts_link function look like this? Because this is where the error is happening.

    function next_posts_link($label='Next Page &raquo;', $max_page=0) {
    global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages;
    if ( !$max_page ) {
    if ( isset($max_num_pages) ) {
    $max_page = $max_num_pages;
    } else {
    preg_match('#FROMs(.*)sGROUP BY#siU', $request, $matches);
    $fromwhere = $matches[1];
    $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");

    Filosofo, yeah my template-functions-links.php is exactly like that.

    When I click on an archive month it displays that message at the top of the screen.

    Is there anyway the $fromwhere would not be getting populated with a table name?

    My friend is having the same problem. Is there a solution?

    I have exactly the same problem, having upgraded from 1.5 to 2.0.3. Is any progress being made in resolving this?

    If there’s any connection, I’va also had problems with updating permalinks – posted in a separate thread

    Only minutes after my original post . . . .

    For me, this problem disappeared once I had updated the Adhesive plugin – even though the old version of this was deactivated at the time of the problem.

    Hope this is other people’s problem too.

    cromagnon99, I don’t use the Adhesive plugin.

    I still can’t get rid of this, does anyone know anything else about it?

    Just upgraded from 1.5 to 2.0.3. At first I suspected my Connection theme had compatibility issues, but now it seems 1.5 themes should generally work with 2.0. I’ve opted for the default link structure, to no avail. Hosting company did upgrade to MySQL 4.1.19 recently — don’t know if this is an issue with PHP (caused me a lot of problems with Perl).

    PS: Deactivated all plugins — same problem.

    I had this same problem when upgrading today. I found that some files on the FTP had not been overwritten with the new versions when uploading the 2.0.3 files, so I went through and deleted the files in the base directory except for wp-config.php and reuploaded. The problem was fixed for me after I did this.

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