NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page mysql error! gah - this keeps annoying me! :(

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-01-2006, 02:06 PM THREAD STARTER               #1 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie 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, 01:04 AM   #2 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
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 is offline  
Old 11-02-2006, 02:14 AM   #3 (permalink)
New Member
Join Date: Jul 2006
Posts: 16
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, 02:18 AM THREAD STARTER               #4 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



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
????: NamePros.com http://www.namepros.com/programming/253267-mysql-error-gah-keeps-annoying-me.html
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, 03:25 AM   #5 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
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
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
????: NamePros.com http://www.namepros.com/showthread.php?t=253267

http://dev.mysql.com/doc/refman/4.1/...ric-types.html
Peter is offline  
Old 11-02-2006, 09:29 AM   #6 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Rep gladly accepted
beaver6813 is offline  
Old 11-03-2006, 02:24 AM THREAD STARTER               #7 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



Originally Posted by beaver6813
Rep gladly accepted
lol.... not subtle
????: NamePros.com http://www.namepros.com/showthread.php?t=253267

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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 07:56 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger