Jump to content

Need help with my banner ad rotation on phpBB forum


sarchi

Recommended Posts

Hi,

 

I tried installing this:

http://simplythebest.net/scripts/DHTML_scripts/javascripts/javascript_54.html

 

....but it caused huge problems for people browsing with Safari and Mac's.

 

I then tried installing this one:

http://www.scripts.com/viewscript/rotating-advertisement-script/6418/

 

....but I get some kind of simple parse error no matter how I configure it.

 

You can see it (the error) in the header of my forum beside the Google ads.

http://www.triumph675.net/phpBB2/

 

The error is always the same no matter what I try.  (tried all their troubleshooting tips)

 

My sponsors are getting annoyed, so if anyone has a quick/dirty fix it'd be MUCH appreciated. :)

 

 

Link to comment
Share on other sites

Thanks, that didn't help though.

 

The code is at the bottom of my overall_header.php file, which is basically an HTML doc.  I tried adding </html> before the script call too....

 

this is the code;

 

.....

<script type="text/javascript"><!--

google_ad_client = "pub-xxxxxxxxxxxx";

google_ad_width = 468;

google_ad_height = 60;

google_ad_format = "468x60_as";

google_ad_type = "text_image";

google_ad_channel ="";

google_color_border = "FFFFFF";

google_color_bg = "F0F0F0";

google_color_link = "0000FF";

google_color_url = "008000";

google_color_text = "000000";

//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 

</script>

</html>

<?php

include_once("http://www.triumph675.net/phpBB2/templates/subSilver/adrotation.php");

echo "<div align='center'>$bannerAd</div>";

?>

 

and this is the code in adrotation.php :

 

 

<?php

$bannerCounter= 1;

$bannerCode[$bannerCounter] =

"<A HREF=\"http://www.rampmotorcycles.com\"><IMG SRC=\"http://www.triumph675.net/phpBB2/templates/subSilver/images/ramp.gif\" BORDER=\"0\" HEIGHT=\"60\" WIDTH=\"468\" alt=\"Click to Visit RAMP Motorcycles\"></A>";

$bannerCounter++;

$bannerCode[$bannerCounter] =

"<a href=\"http://www.oncycles.com\" target=\"_top\"> <img src=\"http://www.triumph675.net/phpBB2/templates/subSilver/images/oncycles-2.gif\" width=\"468\" height=\"60\" alt=\"Click to Visit OnCycles Mall\" border=\"0\"></a>";

$bannerCounter++;

 

$bannerAdTotals = $bannerCounter - 1;

if($bannerAdTotals>1)

{

  mt_srand((double)microtime() * 1234567);

  $bannerPicked = mt_rand(1, $bannerAdTotals);

}

else

{

  $bannerPicked = 1;

}

$bannerAd = $bannerCode[$bannerPicked];

?>

Link to comment
Share on other sites

Your banner code is messed up:

"<a href=\"http://www.oncycles.com\" target=\"_top\"> <img src=\"http://www.triumph675.net/phpBB2/templates/subSilver/images/oncycles-2.gif\" width=\"468\" height=\"60\" alt=\"Click to Visit OnCycles Mall\" border=\"0\">[/url]";

 

Why does it start with an HTML link and end with a bbcode link?

Link to comment
Share on other sites

it looks to me like

 

$bannerAdTotals = $bannerCounter - 1;

 

makes $bannerAdTotals == 1, so you're then trying to pull a random number from 1 to 1:

 

$bannerPicked = mt_rand(1, $bannerAdTotals);

 

I might do this as follows:

 

$bannerCode = array();

$bannerCode[] = "Some URL";

$bannerCode[] = "Another URL";

$bannerPicked = mt_rand(0, count($bannerCode) - 1);

$bannerAd = $bannerCode[$bannerPicked];

 

 

Note: As of PHP 4.2.0, there is no need to seed the random number generator with srand() or mt_srand() as this is now done automatically.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.