Results 1 to 4 of 4

Thread: RAND() error

  1. #1

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909

    RAND() error

    What's wrong with this statement?

    PHP Code:
    $query mysql_query("SELECT link FROM downloads WHERE version='".$version."' ORDER BY RAND() LIMIT 1"); 
    I run this and always get the same entry for a link. There are 3 different rows which match the criteria, but I always get the same row everytime i run the script.....:Bang:

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    what version of mysql are you using?

    also remeber that RAND() is not meant to be a perfect random generator.

  3. #3

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    3.23.54-nt is my mysql version

    and i know it isnt perfect, but i ran it over 200 times and it is always the same output. thats not right

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    well I can see version='$version' it will always be what the $version is, it can't be random. try it like this

    PHP Code:
    $query mysql_query("SELECT link FROM downloads ORDER BY RAND() LIMIT 1"); 
    what is $version and where is it coming from?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width