Hi, I'm trying to make a quick and easy Ad Rotation Script. I made a file, randombanner.php, and it goes as follows: <?php $number=rand(0, 100); if ($number < 50) { echo '<script type="text/javascript"><!-- google_ad_client = "pub-3873295902304841"; //728x90, created 16/12/07 google_ad_slot = "2029938138"; google_ad_width = 728; google_ad_height = 90; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>'; } else { echo '<!-- START CUSTOM WIDGETBUCKS CODE --><div><script src="http://www.widgetbucks.com/script/ads.js?uid=y4cEXhlQhFGjnIVq"></script></div><!-- END CUSTOM WIDGETBUCKS CODE -->'; } ?> Code (markup): When I go to the URL, a random banner is displayed just fine. However, it becomes a problem when I try to include it into the document. I use an include, like this: <?php include 'http://www.XXXX.XXX/randombanner.php';?> Code (markup): Nothing is shown in the document when I do it this way. How to fix? Thanks, Jake.
Try: <?php include (randombanner.php); ?> Note the space between the ; and ? is intentional. edit: I think you still have a potential problem with your conditional statement when the random number is 50. <= might be a better choice.
Your main problem is probably that you are using http path to include the file. Some servers don't support it and it can cause problems, read here: http://www.php.net/manual/en/function.include.php Your safest bet is to use local or absolute path to the file, ie: <?php include ("randombanner.php"); ?> or <?php include ("/www/home/usersite/public_html/banners/randombanner.php"); ?>