Incorrect Integer (2147483647) is inserted into MySQL? Incorrect Integer (2147483647) is inserted into MySQL? php php

Incorrect Integer (2147483647) is inserted into MySQL?


2147483647 is the largest int value for mysql. Just change the type from int to bigint.


Based on your comment of "value being dumped"; the number you are trying to insert is too large for 32-bit systems. The max for 32-bit is 4,294,967,295, and the max for 64-bit is 18,446,744,073,709,551,615. I'd recommend converting your column into a varchar(100) hash rather than an int, or switch to a 64 bit system. Great article about max ints here, and here.


Also, before I get flamed, be sure to read up on SQL injection in case you are not sanitizing variables being posted directly into sql statements.


While I was playing with SQL and MySQL had the same problem MySQL int data type.Modifying data type from int to bigint fixed issue.

MySQL Integer Types http://dev.mysql.com/doc/refman/5.7/en/integer-types.html

ALTER TABLE tablename MODIFY columnname BIGINT;