Re: Problem with rand()



"Mike" <ampeloso@xxxxxxxxx> wrote in message
news:ccc46c96-5185-4871-b7bc-c3aa2f3933c9@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
I am using the rand function to create a UID and have noticed a
problem.
Here is my code:
$s_key = mt_rand(1111111,2147411);
I then insert the number into a Mysql as a Varchar(10) , but every
once in a while i get a value in the db like this:
466582143
What could be going wrong?
Thanks
Mike

Could your platform not allow such large integers?

I just looked at my docs
http://www.php.net/manual/en/language.types.integer.php
and found
The size of an integer is platform-dependent, although a maximum value of
about two billion is the usual value (that's 32 bits signed). PHP does not
support unsigned integers. Integer size can be determined using the constant
PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP
4.4.0 and PHP 5.0.5.

Len



.



Relevant Pages

  • Re: Questions to discover a php guru
    ... world and not too much familiar with the platform. ... Proficient with MySQL ... I'm by no means a php "developer", but I have built a site "from ... How do you backup mysql databases? ...
    (comp.lang.php)
  • Re: Problem with rand()
    ... I am using the rand function to create a UID and have noticed a ... I then insert the number into a Mysql as a Varchar, ... Could your platform not allow such large integers? ... and PHP 5.0.5. ...
    (php.general)
  • Re: I am totally stumped..with this on..LOAD_FILE Mysql+PHP= FSCK!!
    ... What I am trying to do is to upload files and stuff them in a mysql database. ... I copied the temporary file to somewhere else, and then handed it to MySQL..THAT WORKED.. ... Is there a way to force a close on the file..maybe that's the problem Mysql is opening a file that is not flushed to disk maybe? ... I gew the feeling its maintaining its own picture of file objects, and doesn't actually flush to the disk unless you do a copy or close php.. ...
    (comp.lang.php)
  • Re: I am totally stumped..with this on..LOAD_FILE Mysql+PHP= FSCK!!
    ... What I am trying to do is to upload files and stuff them in a mysql database. ... I copied the temporary file to somewhere else, and then handed it to MySQL..THAT WORKED.. ... Is there a way to force a close on the file..maybe that's the problem Mysql is opening a file that is not flushed to disk maybe? ... I gew the feeling its maintaining its own picture of file objects, and doesn't actually flush to the disk unless you do a copy or close php.. ...
    (comp.lang.php)
  • Re: Best development platform? Mac, Windows or Linux?
    ... for a LAMP developer, I use Quanta which is part of the KDE library of ... I develop both on Mac and PC, but personally I like Mac more because ... Development platform I prefer Eclipse (PHP environment) which is cross- ...
    (comp.lang.php)