MySQL Insert Problems

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

MySQL Insert Problems

Post by evilmonkey »

Heelo. I'm using a MySQL db, and I have an auto_increment line called id, as well as a bunch of other columns (varchar, into, etc.)

The problem is, I went up to 127 rows (113 in actuality, 127 by the id numbers), and it refuses to add the 128th. It says:

Duplicate entry '127' for key '1'

I have no idea what that means, but i can't insert rows through my scripts, not through PHPmyADMIN. The max_rows is set to 10 000. What should I do?

Cheers!
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

Are you trying to insert a value into the auto_increment column?

If you are, then this is most likely your problem.

An insert into a table like this should start like:
insert into TABLENAME values(' ', col_2, col_3, etc...

The first insert value must be an empty value since the "auto" of the auto increment will do the rest.

I hope this helps.

Don
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Nope, first value is always empty. Thanks for trying though. Any other suggestions?

Cheers!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

It may be that you are using a TINYINT field to store the autoincrement value. If so then the problem is that a TINYINT field can only store values up to 127 - you probably just need to change your field to a SMALLINT or MEDIUMINT field, depending on how big it will need to be able to grow.

For more info:
http://www.mysql.com/doc/en/Numeric_types.html

Mac
Post Reply