0

PHP代码:

$code=rand(1000000000,9000000000);

$sql=mysql_query("INSERT INTO `form` (`code`,date) VALUES ('$code',now())");

此代码在本地工作,但不能在线工作。保存到数据库的所有代码都是:2147483647。如何解决这个问题?

4

2 回答 2

3

将字段的类型从int更改为bigint

检查这个http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

(11.1.4.1. 整数类型(精确值))

Int 介于-21474836482147483647 之间

BigInt 介于-92233720368547758089223372036854775807之间

于 2012-10-23T12:54:15.913 回答
1
2147483647 = 2^31 − 1 

这是mysql可以表示的最后一个整数。我认为您应该将类​​型更改为“bigint”,一切都会好起来的。

于 2012-10-23T12:57:33.430 回答