Ask a Question related to Coldfusion Database Access, Design and Development.
-
kidvolt #1
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
-
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... -
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... -
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... -
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... -
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... -
Fernis #2
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
-
kidvolt #3
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
-
MikerRoo #4
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
-
kidvolt #5
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
-
MikerRoo #6
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
-
kidvolt #7
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
-
kidvolt #8
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
-
MikerRoo #9
Re: Random Acts of Stupidity
Oh, well I stand corrected.
Funny thing, though: my random code works.
Good luck with your problem.
MikerRoo Guest



Reply With Quote

