Because
TINYINT has a MAX VALUES of 127
pre the mysql docs:
TINYINT[(M)] [UNSIGNED] [ZEROFILL]
A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
if you unsign the column, you can get to 255
I would use something larger, because you will have more than 255 messages (hopefully).
use an unsigned integer
CREATE TABLE chatmessages (id INT UNSIGNED DEFAULT '0' NOT NULL AUTO_INCREMENT,
message text, username varchar(100), UNIQUE id (id);
this will allow for 4,294,967,295 messages.
-----Original Message-----
From: Joris Kluivers [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 04, 2001 5:56 AM
To: [EMAIL PROTECTED]
Subject: insert + AUTO_INCREMENT
hi,
i have a problem
i have a database table created with the statement:
CREATE TABLE chatmessages (id tinyint(6) DEFAULT '0' NOT NULL AUTO_INCREMENT, message
text, username varchar(100), UNIQUE id (id);
I insert records with:
INSERT INTO chatmessages (message, username) VALUES ('this is my message', 'joris');
this works fine (for a while), i can insert messages and retreive them with php.
But after some time i get the error:
ERROR 1062: Duplicate entry '127' for key 1
but how can this be because i've set it to AUTO_INCREMENT.
can someone help me?
thanks in advance
Joris Kluivers
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php