vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I am using RAND() in rapid sequence, possibly on different connections. I expected to get different numbers from RAND(). I didn't. I get the same number within a given timeframe - it's like it's driven entirely by microtime. Am I stuck? I need different numbers for images. The only solution I can think of is to get 'the next image' from the database. to make it look random. but that's not very random. any ideas? |
| |||
| On Sat, 22 Apr 2006 18:47:49 -0700, Jim Michaels wrote: > I am using RAND() in rapid sequence, possibly on different > connections. I expected to get different numbers from RAND(). I > didn't. I get the same number within a given timeframe - it's like > it's driven entirely by microtime. Am I stuck? > > I need different numbers for images. The only solution I can think of > is to get 'the next image' from the database. to make it look random. > but that's not very random. > > any ideas? Generate your random number on the application level? Use an autoincrement column instead of a random one? Start with telling us what problem you're trying to solve rather than telling us your not-working solution. That is, "I want to have a unique file name I can give to an image associated with information stored in a table" instead of "RAND() isn't random enough, so I can't make a file name out of it and guarantee uniqueness". -- 100. Finally, to keep my subjects permanently locked in a mindless trance, I will provide each of them with free unlimited Internet access. --Peter Anspach's list of things to do as an Evil Overlord |
| |||
| "Peter H. Coffin" <hellsop@ninehells.com> wrote in message news:slrne4m0fr.mnd.hellsop@othin.ninehells.com... > On Sat, 22 Apr 2006 18:47:49 -0700, Jim Michaels wrote: >> I am using RAND() in rapid sequence, possibly on different >> connections. I expected to get different numbers from RAND(). I >> didn't. I get the same number within a given timeframe - it's like >> it's driven entirely by microtime. Am I stuck? >> >> I need different numbers for images. The only solution I can think of >> is to get 'the next image' from the database. to make it look random. >> but that's not very random. >> >> any ideas? > > Generate your random number on the application level? Use an tried that. same problem. no solution yet. microsecond resolution of uniqid() isn't fast enough to give me random images. this must be cached in memory at the server or something. > autoincrement column instead of a random one? Start with telling us what > problem you're trying to solve rather than telling us your not-working Trying to generate multiple random images by a onsie-script that selects one hopefully unique image (from an existing table of images that has id numbers) on a web page. At the very least, they should be different images from each other, so they *could* be sequential if I can't get random to work. > solution. That is, "I want to have a unique file name I can give to an > image associated with information stored in a table" instead of "RAND() > isn't random enough, so I can't make a file name out of it and guarantee > uniqueness". > |
| ||||
| "Jim Michaels" <NOSPAMFORjmichae3@yahoo.com> wrote in message news:fKKdnXFcNOVJsNHZnZ2dnUVZ_uWdnZ2d@comcast.com. .. > > "Peter H. Coffin" <hellsop@ninehells.com> wrote in message > news:slrne4m0fr.mnd.hellsop@othin.ninehells.com... >> On Sat, 22 Apr 2006 18:47:49 -0700, Jim Michaels wrote: >>> I am using RAND() in rapid sequence, possibly on different >>> connections. I expected to get different numbers from RAND(). I >>> didn't. I get the same number within a given timeframe - it's like >>> it's driven entirely by microtime. Am I stuck? >>> >>> I need different numbers for images. The only solution I can think of >>> is to get 'the next image' from the database. to make it look random. >>> but that's not very random. >>> >>> any ideas? >> >> Generate your random number on the application level? Use an > > tried that. same problem. no solution yet. microsecond resolution of > uniqid() isn't fast enough to give me random images. this must be cached > in memory at the server or something. > >> autoincrement column instead of a random one? Start with telling us what >> problem you're trying to solve rather than telling us your not-working > > Trying to generate multiple random images by a onsie-script that selects > one hopefully unique image (from an existing table of images that has id > numbers) on a web page. At the very least, they should be different > images from each other, so they *could* be sequential if I can't get > random to work. > >> solution. That is, "I want to have a unique file name I can give to an >> image associated with information stored in a table" instead of "RAND() >> isn't random enough, so I can't make a file name out of it and guarantee >> uniqueness". >> > > found the solution. the browser was cacheing the image and therefore giving me duplicates. the random number generator in the DB is fine. I don't have a "microtime" problem with it. All my thinking was bogus. I've been wrong before. |
| Thread Tools | |
| Display Modes | |
|
|