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!

INT field won't go beyond 127 1

Status
Not open for further replies.

sinbadly

Technical User
Mar 16, 2006
126
GB
Points INT(3) is a row in a table. I use PHPMyAdmin.

Each week, I have to update the numbers in the row, and this week some of the rows should read 146, or 140, or 136.

However, I enter the number - say 146 - but when it is saved, it turns the nuumber to 127. And numbers I have entered of more than 127 display only 127!

Help! In desperation, I changed the INT to INT(4) and then INT(5) and changed the name of the row. None of these affect the result, which remains at 127.

Is this a clear indication of insanity, or something a little less disturbing, please, Experts?
 
Are you sure it's not declared as TINYINT, which has a range of -128..127?
 
Thanks, Tony. How many times do you hear, 'Well, I never knew that.' Well, I have to say it, I never knew that. I use TINYINT for ids in tables ... it must tbe auto_increment that makes it work ok there.

Thanks again, Tony. Once again you have helped enormously. All the best.
 
auto_increment works on any integer column, from TINYINT through MEDIUMINT, INT, and BIGINT

it's the fact that you've chosen TINYINT that's causing you grief, not whether it's auto_increment

as tony said, TINYINT can hold numbers only up to 127



r937.com | rudy.ca
 
Since MySQL's auto_increment feature doesn't normally generate negative numbers, I make a point of defining any auto_increment column as unsigned.

A tinyint, for example, can store a value from -128 to 127, but an unsigned tinyint goes from 0...255. The second range is more useful to me.




Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top