Log in

View Full Version : php Ad Rotator


Licker4U
2007-11-26, 10:47 AM
I've been using this ad rotator script for 6 months and it worked fine. Now I notice the ads don't appear at all. Any ideas why it would just quit all of a sudden? |huh

<?php



// TEST MODE - SET TO on OR off
$test_mode = "off";



// RESET ADS
$ads = "";

// AND PICK AN AD

// COUNT ADS

$dirhandle = opendir("ads/");
while($filename = readdir($dirhandle)) {
if (ereg ("htm", $filename)) {
$ads[]=$filename;
}
}
closedir($dirhandle);

$number_of_ads = count($ads);

if($test_mode == "on") {
print("There are <B>$number_of_ads</B> ads in the ads folder<BR>");
}

// SET THE RANDOM SEED
mt_srand(doubleval(microtime()) * 100000000);

// PICK A RANDOM NUMBER
$random_number = mt_rand(1, $number_of_ads);

if($test_mode == "on") {
print("I am going to show advert <B>$random_number</B> of <B>$number_of_ads</B><BR><BR>");
}

$array_number = $random_number -1;

include("ads/$ads[$array_number]");

?>

N J
2007-11-26, 12:47 PM
server setting seems most likely if you didn't change anything - sure php is allowed? Or even if html is executed as php if you sites are .htm(l)?

I'm no programmer, so best advice is to ask your host to check the logs.

shunga
2007-11-26, 12:58 PM
With test mode on what's the output?

Licker4U
2007-11-26, 01:34 PM
server setting seems most likely if you didn't change anything - sure php is allowed? Or even if html is executed as php if you sites are .htm(l)?

I'm no programmer, so best advice is to ask your host to check the logs.

I was thinking it was a server issue and sent a trouble ticket to my host. Just can't believe they would change something to make the script stop after six months.

With test mode on what's the output?

Nothing. I think that is a test so potential users can see how it works

shunga
2007-11-26, 02:43 PM
if($test_mode == "on") {
print("There are <B>$number_of_ads</B> ads in the ads folder<BR>");
}

I'm wondering what that outputs. Offhand either it can't find the ads, or it can't display them. If that test output comes back with $number_of_ads greater than 0 then the problem is narrowed down.

Licker4U
2007-11-26, 03:22 PM
I think the tech at my host is getting things fixed. Don't know what he's doing but "rotator1" is working on the index page but "rotator2" isn't working on the main page. He's on top of it.|thumb