php random image and glob (script works! Problem on the include)?

jaz

New member
ok my ranBanner.php is at /scripts/ranBanner.php

This script works by itself if I access it directly... However if I include script from index page like <?php include('scripts/ranBanner.php'); ?> all that is outputted it the formatting and no file name.. (output from index) <img src="" width="300" border="1" alt="banner">

now even if the image location was off in the output, I could work with that but I get nothing :(
Additionally, I have tried calling echo $banner; in the index after include and it still doesn't work

Thanks for suggestions / help

ranBanner.php contents..

<?php
$pics = glob('../images/banners/{*.gif,*.jpg,*.png}', GLOB_BRACE | GLOB_NOSORT );
$pic = $pics[array_rand($pics)];
$banner =("<img src=\"$pic\" width=\"300\" border=\"1\" alt=\"banner\">");
echo $banner;
?>
Adding the / in the beginning of scripts in <?php include(' /scripts/ranBanner.php'); ?> on the index page didn't help :(
 
Back
Top