Forums

SQL error when adding new post (8 posts)

  1. djeyewater
    Member
    Posted 11 months ago #

    I just upgraded my wordpress from 3.1.2 to 3.1.3. The upgrade was done by replacing the existing installation folder with the latest version, not using wordpress' built in upgrade facility.

    After copying across the new version, I visited the admin area, but didn't get a message about the database needing to be upgraded. After investigating I understand that this is because the database version is the same for 3.1.2 and 3.1.3, and so didn't need to be upgraded.

    Now when I click to add a new post, the new post page opens, but at the top of the page it says:

    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 ( (post.post_status='inherit' AND post.post_' at line 5]
    SELECT *,parent.post_status FROM wp_posts parent, wp_posts post WHERE (parent.post_status='publish' OR parent.post_status='private') AND post.ID= AND ( (post.post_status='inherit' AND post.post_parent=parent.ID) OR (parent.ID=post.ID) ) AND post.post_type!='nav_menu_item' AND post.post_type!='revision' AND post.post_type!='attachment'

    Can anyone help me with fixing this error?

    Thanks

    Dave

  2. esmi
    Theme Diva & Forum Moderator
    Posted 11 months ago #

    Do you have a pre-upgrade database backup?

  3. djeyewater
    Member
    Posted 11 months ago #

    I do, would you suggest replacing the database with the pre-upgrade backup?

  4. esmi
    Theme Diva & Forum Moderator
    Posted 11 months ago #

    First try:
    - switching to the Twenty Ten theme

    - resetting the plugins folder by FTP or phpMyAdmin.

    - re-uploading all files & folders - except the wp-content folder - from a fresh download of WordPress.

    - running an upgrade manually using wp-admin/upgrade.php.

  5. djeyewater
    Member
    Posted 11 months ago #

    Thanks for the help, I have followed your advice and think I have narrowed it down to the relevanssi plugin. I've added the relevanssi tag to this thread now, so hopefully someone who knows about that plugin will find this thread to help out.

  6. msaari
    Member
    Posted 11 months ago #

    Well that is indeed SQL code from Relevanssi, but I don't know what's wrong with your site, I've had no trouble with Relevanssi with either 3.1.2 or 3.1.3.

  7. djeyewater
    Member
    Posted 11 months ago #

    I did some more investigating, and the error only occurred when I had another plugin activated. This other plugin used $wpdb->show_errors();

    I tried a brand new installation of wordpress with new database and new download of relevanssi, and added $wpdb->show_errors(); to the relevanssi.php file. The error occurs when this is added, so it seems there is a bug with relevanssi, just usually the error is hidden.

    Whether it is worth fixing an error that is probably hidden for all users I will leave up to the developers, and I understand if they would rather concentrate on other things.

  8. msaari
    Member
    Posted 11 months ago #

    Hmm, I checked this out and the problem is that there's a value missing from the SQL query. Looks like a fix introduced in the latest version causes this error...

    Actually, this is an interesting bug - for some reason WordPress calls a hook when the add post page is opened, when the hooks should be fired only after editing a post. I wonder if this is actually a WordPress bug... I'll have to investigate.

Reply

You must log in to post.

About this Topic