The limit to tinyint is 255... use int.

Jim MacCormaic wrote:

Hi all. I'm new here, currently implementing my first PHP/MySQL website on an iMac running Mac OS X v.10.2.3.

All has been going really well until just now while I was adding records to the MySQL database. I have a table which includes an auto-incremented field which is set as the Primary key. I was happily entering information and then suddenly got a warning of an error in my MySQL query, telling me that I had a 'duplicate entry "255" for key 1'.

I've checked the relevant table in PHPMyAdmin and, sure enough, under Row Statistic in the Structure option it gives a value of 255 for the Next Autoindex even though that value was already assigned in the previous record. I feel as if I've hit a brick wall on this one. I ran Check Table, Analyze Table and Optimize Table in PHPMyAdmin Operations and all reported 'OK'. I'm using a PHP form to insert the records and have code included to print out the MySQL query and to report errors (hence the warning which I received). The field in question is of type tinyint(4), unsigned, not NULL and, as stated, is the Primary key and set to auto-increment.

Have I hit some sort of limit by reaching an id of 255? If so, can I fix this? Any help would be appreciated, as my database has to all intents and purposes lost its functionality once I cannot add further records.

Jim MacCormaic
Dublin, Ireland

The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to