Re: PHP random n. problem?

From: Date: Fri, 14 Jul 2000 17:57:15 +0000
Subject: Re: PHP random n. problem?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-6686@lists.php.net to get a copy of this message
Hehe, I had some trouble with the rand function too, a while back..... it turned out i was stupid. Hopefully, if you are stupid like me, the solution will be simple :) you have to seed the rand function.... if you didnt do that, it isnt too random. someone on this newsgroup kindly helped me out and told me to seed it like so: srand((double)microtime()*1000000); and then just call rand() and it worked wonderfully. Hope this helped Ed "Jacek" <jacek@oi.idl.krakow.pl> wrote in message news:Pine.LNX.4.21.0007141944270.15153-100000@oi.idl.krakow.pl... > Are there any known problems with generating random numbers in PHP? > > I'm using php 4.0.1pl2 on RH 6.2. > > I installed the banner script phpAds - which works fine, with one > exception: random banner selection seems not to be very "random". > Instead of each banner having the same probability, and thus - periodity > of display, some banners get displayed very often, whereas others don't > get displayed at all! > > All banners belong to the same group - so they really SHOULD get displayed > equally often! I suspect some major random number generator bug - if I > change the banners database (change order, delete and put back again > etc.) - different banners "dominate' while some other banners get > 'discriminated'. > > ...or have done something wrong with the phpAds itself? > Any clues? > > Jacek Juda > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#6686) next »