[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 11-01-2006, 01:06 PM   #1 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


mysql error! gah - this keeps annoying me! :(

This is the error I get when I try to input more records into a table.
Code:
Duplicate entry '127' for key 1
The "auto_increment" value is "127".

Why is this happening? How can I stop it? I have tried to change the auto_increment value, but it won't let me!

Thanks
Tom
PoorDoggie is offline  
Old 11-02-2006, 12:04 AM   #2 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough


Erm thats slightly confusing, when inputting into a table i always set the primary key to INT type. Set the value to 255 (thats the max you can go up to) and then set it to auto_increment. Try changing the structure of the table using the way i said above. Tell me how it goes.
__________________
-Beaver6813.com V5 Soon!
beaver6813 is offline  
Old 11-02-2006, 01:14 AM   #3 (permalink)
New Member
 
Join Date: Jul 2006
Posts: 16
0.00 NP$ (Donate)

kzaid1 is an unknown quantity at this point


A primary key can't be duplicated it has to be unqiue
that why people usually set it to auto_increment so sql
automatically sets the key. beaver6813 will work and
if you do want to set it like beaver6813 stated then you
would have to check if the key exists in the table before
inserting a new one
__________________
kzaid1 is offline  
Old 11-02-2006, 01:18 AM   #4 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
Originally Posted by kzaid1
A primary key can't be duplicated it has to be unqiue
that why people usually set it to auto_increment so sql
automatically sets the key. beaver6813 will work and
if you do want to set it like beaver6813 stated then you
would have to check if the key exists in the table before
inserting a new one
nomally though, it all just works dosen't it?

I usually put the value "NULL" for the primary key field eg:
Code:
INSERT INTO table VALUES (NULL, 'PoorDoggie', 25);
dosen't that work?

Thanks
Tom

UPDATE: Ah... i had the primary key field as a "tiny_int" not an "int". This is probably why? It appears to be working now I have changed it.
PoorDoggie is offline  
Old 11-02-2006, 02:25 AM   #5 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Quote:
Originally Posted by PoorDoggie
UPDATE: Ah... i had the primary key field as a "tiny_int" not an "int". This is probably why? It appears to be working now I have changed it.
Yes that was the cause of your problem. The highest value for a tiny_int is 127

http://dev.mysql.com/doc/refman/4.1/...ric-types.html
Peter is offline  
Old 11-02-2006, 08:29 AM   #6 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough


Rep gladly accepted
__________________
-Beaver6813.com V5 Soon!
beaver6813 is offline  
Old 11-03-2006, 01:24 AM   #7 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
Originally Posted by beaver6813
Rep gladly accepted
lol.... not subtle

I would be glad to give you some rep lol - I always forget.
PoorDoggie is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 07:52 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85