[resolved] Getting an error when creating new post (3 posts)

  1. vscarpenter
    Posted 9 years ago #

    Hi there. I just did an upgrade to WordPress 2.0 from 1.5.2 and the upgrade seem to go fine. Minor issues were around some rewrite not working for pages.

    Now when I try to create a new POST, I get an error WordPress database error: [Duplicate entry '0' for key 1]. When I look in the database, there is a post with an ID of 0 that was the first post I created after the upgrade. The last number of the post is 522 but the new post always wants to use ID #0 instead of incrementing the next ID. Please help.

    Here's more on the database post error:

    WordPress database error: [Duplicate entry '0' for key 1]
    INSERT INTO wp_posts (post_author, post_date, post_date_gmt, post_content, post_title, post_status, comment_status, ping_status, post_name, post_modified, post_modified_gmt) VALUES (1, '2006-01-29 02:45:29', '2006-01-29 06:45:29', 'BLOG ENTRY HERE', 'Daily Del.icio.us for Jan 28, 2006', 'publish', 'open', 'open', 'delicious-1138435200', '2006-01-29 02:45:29', '2006-01-29 06:45:29');

    WordPress database error: [Duplicate entry '0' for key 1]
    INSERT INTO wp_post2cat (post_id, category_id) VALUES ('522', '6');

  2. Kassad
    Posted 9 years ago #

    First of all: BACKUP your database!
    This is mysql issue probably version difference.
    Check the dump according to this:

    "MySQL: Duplicate entry '0' for key 1

    I ran into this problem when trying to insert a row without specifying the value for the primary key, which was not set AUTO_INCREMENT. If your primary key is not AUTO_INCREMENT, then try specifying its value when you insert a new row.

    I solved my problem by setting the column to AUTO_INCREMENT. "

    I ran into the same problem at a time but I could not remember exactly how it was solved.
    Though, it is sure that it relates to the id field definitions in mysql.
    Generally default values are:
    ... NOT NULL '',
    ... NOT NULL '0',

    I think, the AUTO_INCREMENT is your option.
    Surely, there are people who know better this problem, I hope they call in.

    But as I said, BACKUP your database before you start tinker with it.

  3. vscarpenter
    Posted 9 years ago #

    Hi Kassad. You are totally right on -- I used MySQL Administrator to migrate from one server to another using backup and restore and I didn't even bother checking that the integrity of the table was maintained. All of the tables primary ID key was missing it's AUTO INCREMENT flag. Yikes :)

    Thanks for your help. Quick cleanup and I am up and running.

Topic Closed

This topic has been closed to new replies.

About this Topic