Random Acts of Stupidity

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Random Acts of Stupidity

    Ok, my server used to do random queries like a demon - refresh the page and
    things were different. Anymore, the randoms just stay the same like the page
    or perhaps the query is being cached. So, please, what have I done?

    Save me from myself!

    CFMX6.1.

    kidvolt Guest

  2. Similar Questions and Discussions

    1. flash movie acts differently on different browsers
      hi i have created an online calendar, you can see it on http://www.omrihecht.com/calendar/calendar.html this application uses php as well which is...
    2. Javascript acts funny in IE & not Firefox
      I have a page uploaded on a server with 5 buttons that control a sub-menu selection thru javascript. When I preview the page in Firefox it acts like...
    3. ColdFusion Stupidity
      A customer of mine has had problems with one of my software components on MX7. I finally tracked down the error and its due to the Macromedia...
    4. CF7 - cfgridcolumn mask attribute acts strange
      Hi all, When I use the "mask" attribute in the cfgridcolumn tag, and fill in the value like "999". The user can still enter anything he want's...
    5. Acrobat 6 Acts Strange with web/browser form submission
      I have an application that works well to submit form data using FDF to ASP that saves the information on the server-side. It works beautifully with...
  3. #2

    Default Re: Random Acts of Stupidity

    Have you ruled out the possibility that your browser might cache the page? Do all users get the same page (without randomations) all the time?

    Fernis Guest

  4. #3

    Default Re: Random Acts of Stupidity

    Yes, ruled out. Have the same issue regardless of browser or user. Give it a try.

    [url]http://www.tsdroadrally.com[/url]

    The products page should come up in a random order.

    And thanks for the reply.
    kidvolt Guest

  5. #4

    Default Re: Random Acts of Stupidity

    There's a chance that CF's cache is using old code. You can clear it.

    But, most likely it is in the logic of how the products query is being run.
    You need to post code and expected results.

    Anyway, on CF6, clear the cache as follows:
    1) Stop the CF App server.
    2) Find your cache directory. Its usually something like
    "C:\CFusionMX\wwwroot\WEB-INF\cfclasses"
    3) Delete every file in that directory.
    4) Restart Coldfusion.


    MikerRoo Guest

  6. #5

    Default Re: Random Acts of Stupidity

    No problem, here's the code:

    <CFQUERY Name="GetProducts" Datasource="#session.DSN1#">
    SELECT *
    FROM Products
    ORDER BY rnd(Product_ID)
    </CFQUERY>

    I expect it to return the records in a random order. I dumped all the files
    in that folder and am still not seeing a random order result but that looked
    like one issue and I'll keep working on it. Thanks!

    Does it look random to you on a refresh?

    kidvolt Guest

  7. #6

    Default Re: Random Acts of Stupidity

    No, it doesn't randomize for me and I think I see why.

    What DB system are you using?
    The Rnd() function doesn't really return random numbers, they are pseudo
    random -- which means that the first run through will generate the same
    sequence every time.

    Depending on what DB you are using, that query will:
    1) Not return changing results at all.
    or 2) Only change results when the table records change
    or 3) Return random results only on random (a small percentage) runs!
    or 4) Randomly throw an error.

    First, do you really want random? How about "random" that doesn't repeat
    instead -- so that browsers do not see the same product twice until they have
    seen every product at least once?
    The second approach is more typical and is covered in Ben Forta's
    books/tutorials (and probably elsewhere).

    For the immediate problem, what DB are you using?
    Try using CF's RandRange() function (you can also initialize it with a
    millisecond seed using the Randomize function).

    You can call the existing query a random number of times. It might work (but
    is not efficient).
    Or the best way is to get a list of ID's and use CF to select random ones.

    I'm pressed at the moment, so I won't write the code for you -- but you should
    be able to figure it out easily.

    Regards,
    -- MikeR


    MikerRoo Guest

  8. #7

    Default Re: Random Acts of Stupidity

    Ok, this is getting crazy. I have used that code in numerous places for a long
    time and it always worked. I have entire sites based on it and those sites
    work wonderfully on other servers, just not on mine.

    One more piece of missing info:

    We installed the newest version of CFMX 7. We had some issues with it and
    removed it and re-installed CFMX 6.1. We also enabled caching thinking it
    would speed up the queries but when we did, the random stuff no longer worked.
    I have gone through and removed all the cached files and set cached queries to
    ZERO. Also I am not saving the class files. STILL I can not get random
    results on my queries (Access tables) when it used to work just fine. Is there
    something left over from the newest CF that could be causing the issue? I
    REALLY do not want to clean the drive and start over. And I really need to
    return to my previous world of randomness. So clearly the code works just fine
    - did for years. Something has changed with the server.

    Who can tell me what?

    kidvolt Guest

  9. #8

    Default Re: Random Acts of Stupidity

    Oh, and baloney on that not returning random results every time. We write
    surveys and those customers want random order on their question listings. We
    can sit here and refresh the page and EVERY TIME the order is shuffled from
    what it was previous. So I am not sure why you would say that it is pseudo.
    I'll be glad to provide a link if you want to check.

    kidvolt Guest

  10. #9

    Default Re: Random Acts of Stupidity

    Oh, well I stand corrected.

    Funny thing, though: my random code works.

    Good luck with your problem.
    MikerRoo Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139