SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Duplicate entry '0' for key 1???

    I am trying to add content to a database, and when I do I get the error which is in the subject of this thread. It isn't a duplicate entry at all. I have tried changing the datatype from int(11) to unsigned bigint(20) - that has not worked for me. I have tried searching Google for the answer to the problem, but haven't been successful, so that is why I am posting the problem here. So can someone please help me solve this problem? Thanks in advance.

  2. #2
    SitePoint Evangelist
    Join Date
    May 2006
    Location
    Denmark
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you forgot to add auto_increment on a field you wanted to auto increment. Anyways, the error means that there is already another row in the database that has the same PK as the one you are inserting now.

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    if daniel0's reply does not solve it for you, please do a SHOW CREATE TABLE for your table, and then show us the query that got the error
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have recreated the table again. There was only one small row of content in it, so it didn't matter to me. I believe that the solution to the problem, is that I forgot to create the primary key as autoincrement.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •