Random Image Problem
Posted: Sat Jan 11, 2003 12:19 pm
I've created a random banner script, and am having a strange problem. I have a file called "banners.lst" which contains the names of the banner files. The script looks like this:
I then call the script like this from an html file:
Weird thing happens, it works fine most of the time, but every once in a while it doesn't load an image, just gives the Internet Explorer corrupted/nonexistant image box (red x with alt text). I tested it with a very small amount of images (4), none of them are corrupt, as all of them loaded at some time. What I think might be happening is that a blank line is being appended to my banners.lst file, and the script is trying to load the blank line. Does anyone either a) know how to stop this from happening or b) see something other than that which would cause this not to work? Thanks for input.
Code: Select all
<?php
//bnr.php
$banners = file("banners.lst");
header("Location: " . $banners[rand(0,sizeof($banners))]);
?>Code: Select all
<IMG SRC="bnr.php" WIDTH="468" HEIGHT="60" ALT="random banner">