in reply to Perl and MySQL - getting a random record

I get the feeling that perhaps your browser is caching the image that the script returned the first time. Look into adding 'Cache-control', 'Pragma', and/or 'Expires' http headers. Looking at your code even further, where is $imageurl coming from in the Get_Banner_Rotator subroutine? I don't see that declared anywhere... Even worse now... you have a my ($dbh ...); at the top of the sub and then you use it as the database handle. You have to pass the db object into the sub.

As for the query you have to get a random row from the database, it's correct. I recommend cleaning up the code a bit first. As well, I'm not sure whether you already do or not, but I suspect that your script is missing -w and 'use strict'. Add those on if they are missing. They'll make your life so much easier :)


      C:\>shutdown -s
      >> Could not shut down computer:
      >> Microsoft is logged in remotely.
    

Replies are listed 'Best First'.
Re: Re: Perl and MySQL - getting a random record
by powerhouse (Friar) on Feb 06, 2003 at 00:47 UTC
    I do have -w turned on.

    $imageurl, That is defined when the script first executes, what it does is call a subroutine similiar to get_settings(). $imageurl is url() with the /script stripped off. If the page was called through HTTPS, then it is also calling the images with https. then in the Perl code when I am writing a image tag, I put it as src="$imageurl/path/to/image.gif" like that.

    In the databases I put {{imageurl}} then I just switch that with $imageurl.

    Anyways. the current version of MySQL installed is 3.23.54
    I do have another account on this same server that does use RAND() to get a random id which is the name of the image, without the extension. I do that on that site to show sample products out of our database of over 2000 products. it shows 1 on the home page, and it's different every time the page loads.

    In regards to the current site I'm developing, I did clear out my Computers Cache before I reaload it a few times, but it was still record 1. I reloaded the page about 18 to 20 times. Over and over, often clearing the cache first. I also have IE set to check for new pages with every visit.

    I'll add the expires to it to see if that helps. Just in case.

    Thank you for your advice I really DO appreciate it.

    thx,
    Richard