SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2010
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Duplicate entry 'root' for key 2

    i have this error


    DB Error: Duplicate entry 'root' for key 2 : DB Error: Duplicate entry 'root' for key 2

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,491
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    You are trying to insert a value ('root') that already exists in the second unique key you've specified when creating the table.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2010
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i don't know how to solve that,

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,491
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    At least two possibilities:
    1) If you need to have duplicate values in that column, get rid of the unique key
    2) if the values in that column must be unique, don't insert a duplicate value

    If the value has to be unique, and the duplicate value comes from user input, then you could show a message to the user when the query returns a duplicate key error.


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
  •