Click to See Complete Forum and Search --> : mobile number as int


k0r54
09-25-2008, 04:03 PM
I have my database field and it is an int with 11 digits and unasigned zero.

I want it to record mobile numbers but when in phpmyadmin I enter the number it changes it to a completly different number

If i run this query : -
UPDATE `web182-xx`.`user` SET `mobile` = '07969626821' WHERE `user`.`id` =4 LIMIT 1 ;

I then click browse and it shows as 04294967295

Thanks
Adam

DARTHTAMPON
09-25-2008, 04:35 PM
why are you using an int to store a phone number? Are you planning on doing any math with them?

4294967295 I believe is an error return code, for tying to stick to big of a value into your specified data type. (UINT_MAX)

NogDog
09-25-2008, 05:01 PM
4294967295 is the largest number that can be represented by an unsigned INT field. As stated in the previous reply, it probably makes more sense to use a VARCHAR field, as a phone number is really a string, not a numeric value; but if you really have a reason to store it as a numeric value, you could use a BIGINT field. (Be aware though that if you try to use it as a number in PHP, the largest signed 32-bit integer value is 2147483647.)

felgall
09-25-2008, 06:01 PM
Storing a phone number in a numeric field also loses any leading zero on the number.