Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP - can't add rows past a certain id number (127) 1

Status
Not open for further replies.

grahamprice

Programmer
Mar 31, 2004
1
GB
Hi there,
got a prob which i hope someone can help me with.
I've got a table which has about 70 rows in. The rows' ids start at 1, have a large gap in the middle, then range up to 127. If I try to add a new row with an autoindexed new id, I get the following MySQL error: duplicate entry '127' for key 1.
If I add a new row with a lower id, e.g. 6, there are no issues - it works fine. If I delete row 127, or give it a lower number, I can then add a new row as normal, but then the error happens again for all subsequent rows.

Everything was working fine with the page that adds new rows until it got to 127. Is this some kind of magic number I don't know about?
 
127 is the maximum value you can store in a signed TINYINT field. If your field is a signed TINYINT, then you can expand it to a bigger integer field, for example:
- signed SMALLINT (range -32768 .. +32767);
- if it has no negative values, a TINYINT UNSIGNED (range 0 .. 255);
- or one of many other bigger integer fields.

The syntax is:
[tt] ALTER TABLE tblname MODIFY fldname SMALLINT
ALTER TABLE tblname MODIFY fldname TINYINT UNSIGNED[/tt]

etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top