SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: PHPmyAdmin

  1. #1
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK...here is a strange problem. I am getting this error when I try this INSERT statement.

    INSERT INTO po_gallery_images (gid, id, thumb_image, large_image, text) VALUES ('10', '', 'misc_01_thumb.jpg', 'misc_01.jpg', '')
    MySQL said: Duplicate entry '127' for key 1

    I first got it with PHPMyAdmin, then I tried it command line and got the same error. I don't know where it is coming from. Here is a description of my table.
    Code:
    FIELD        TYPE        NULL    EXTRA
    gid          tinyint(4)  No  0 
    id           tinyint(6)  No    auto_increment
    thumb_image  tinytext    No   
    large_image  tinytext    No   
    text         tinytext    Yes
    I would guess that key 1 would be the GID? If so, then the error must be wrong because there are only 10 entries (1-10) in that table so far. I just looekd at the number of entries in the table so far. There are 127 entries. It seems as if the table is corrupted or is only allowing me a certain number of entries and I know that has to be wrong.

    I even tried to enter 128 in the ID field manually and it gave me the same error.

    Anyone have any ideas?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you try the old

    INSERT INTO po_gallery_images set gid = 10, thumb_image = 'misc_01_thumb.jpg', large_image = 'misc_01.jpg';
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Your ID column is maxed out. TINYINT is too small a number for use as a primary key in anything but the smallest tables, because it only allows values between -128 and 127.

    Try:

    ALTER TABLE po_gallery_images CHANGE COLUMN ID ID UNSIGNED INT NOT NULL AUTO_INCREMENT PRIMARY KEY

    This will change your ID column into an UNSIGNED INT, which should last you considerably longer.
    <Edited by kyank on 01-23-2001 at 11:15 PM>
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kevin just out of curiosity's sake what would be the max for tinyint(4) I thought it would be 9999 but apparently I am mistaken, or is 7 * 4 or something?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    See updated message above. TINYINT allows numbers from -128 (-2^7) to 127 (2^7-1). UNSIGNED TINYINT allows from 0 to 255 (2^8-1).
    <Edited by kyank on 01-23-2001 at 11:18 PM>
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I just ran a test and got the same error at 127 as Andy, I was just curious I always use int(11) UNSIGNEd for my auto-increment PRIMARY KEY fields.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yup, UNSIGNED INT allows numbers from 0 to 4294967295 (2^32-1). Much more breathing room.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  8. #8
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    man...I knew it had to be something like that...you guys are a lifesaver...I usually do unsigned anyway because I never work with negative numbers. I guess I just must have forgotten.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes


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
  •