The value is inserted as 2147483647 into the database

All phone numbers that I am trying to log into my database are inserted as 2147483647.

Database field integer(11).

Before the phone number is inserted, it executes the following code to remove all spaces, dashes and brackets:

if (!empty($hphone)) $phone = $hphone;
else if (!empty($HomePhone)) $phone = $HomePhone;
else if (!empty($Phone1)) $phone = $Phone1;
$phone = preg_replace("/[^0-9]/", "", $phone);

Why does he insert a phone number 2147483647every time, no matter what phone number?

+4
source share
2 answers

If you can, convert the phone number to the VARCHAR field, do not store it as a signed (or unsigned) numeric value (int, bigint, double, etc.).

INT MySQL 2147483647 . , , .

, 555-555-5555, (5555555555 > 2147483647), 2147483647.

BIG INT . , :

   +02 112020 10020  
   1-333-232-9393 x203

BTW: , - ,

, 0 , , :

 021-392-9293

213929293

+12

, bigint, int , 2147483647.

, , , 2147483647, 2147483647.

mysql:

http://dev.mysql.com/doc/refman/5.0/en/integer-types.html

+1

Source: https://habr.com/ru/post/1529311/


All Articles