SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
Thread: PHPmyAdmin
-
Jan 23, 2001, 22:06 #1
- 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 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
-
Jan 23, 2001, 23:06 #2
- 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.
-
Jan 23, 2001, 23:12 #3
- 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
-
Jan 23, 2001, 23:14 #4
- 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.
-
Jan 23, 2001, 23:15 #5
- 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
-
Jan 23, 2001, 23:19 #6
- 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.
-
Jan 23, 2001, 23:22 #7
- 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
-
Jan 23, 2001, 23:28 #8
- 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