No Matter What I Do The Same Value Is Being Stored In MySQL Table Field
I have a MySQL table, with the field ('ad_id'). I store variables in different fields with PHP. One of these fields, the 'ad_id' field as mentioned above, stores the same exact nr
Solution 1:
Camran you number is too big if you take a look at mysql documentation here it says:
Type N byte min value max value
INT 4 -2147483648 2147483647
You should generate a smaller random number also if you need that to be random you can use the MySQL RAND function.
Solution 2:
The number 668244234626 is out of range for an integer. It's being truncated to the max value for an integer, which is 2147483647.
If you run your INSERT statement in a MySQL client, you get this result:
Query OK, 1 row affected, 1 warning (0.00 sec)
Then if you show warnings:
mysql> show warnings;
+---------+------+------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------+
| Warning | 1264 | Out of range value for column 'ad_id' at row 1 |
+---------+------+------------------------------------------------+
I notice you declare ad_id INT(13). Note that the argument 13 has no effect on the range of values that you can store in the integer. A MySQL integer data type always stores a 32-bit number, and the value you gave is greater than 2.
If you need to store larger values, you should use BIGINT.
Post a Comment for "No Matter What I Do The Same Value Is Being Stored In MySQL Table Field"