I am trying to implement a php image rotating script that is detailed here at a list apart
http://www.alistapart.com/articles/betterrotator
I can't get it to work though... (no rotating). The page I have added the script to is here:
http://www.inspired-evolution.com/
I *believe* I am doing every thing correctly, so I am puzzled as to why no rotation.
the php code I am using is:
Code: Select all
<?php
$IMG_CONFIG_FILE = 'images.ini';
function showImage( $ini=null ) {
global $IMG_CONFIG_FILE;
# if no custom ini file has been specified, use the default
$ini_file = $ini ? $ini : $IMG_CONFIG_FILE;
# read the config file into an array or die trying
$images = @parse_ini_file($ini_file,true);
if (! $images) {
die('Unable to read ini file.');
}
# pick a random image from the parsed config file
$img = array_rand($images);
# get the selected image's css id if one exists
$id = $images[$img]['id'] ?
sprintf( ' id="%s" ', $images[$img]['id'] ) :
'';
# get the selected image's css class if one exists
$class = $images[$img]['class'] ?
sprintf( ' class="%s" ', $images[$img]['class'] ) :
'';
# get selected image's dimensions
$size = @getimagesize( $images[$img]['src'] );
# if an url was specified, output the opening A HREF tag
if ( $images[$img]['url'] ) {
printf(
'<a href="%s" title="%s">',
$images[$img]['url'],
$images[$img]['title']
);
}
# output the IMG tag
printf(
'<img src="%s" alt="%s" %s %s%s/>',
$images[$img]['src'],
$images[$img]['alt'],
$size[3],
$id,
$class
);
# if an url was specified, output the closing A HREF tag
if ( $images[$img]['url'] ) {
echo('</a>');
}
}
?><?php require ('rotate.php'); ?><?php showImage () ;?>
the images in the images.ini file are listed exactly as shown in the ALA article
eg:
[ReachyourPeak]
src = images/logo_header3.jpg
alt = Inspired-Evolution.com - Reach your Peak!
title = Inspired-Evolution.com - Reach your Peak!
[LookintotheFuture]
src = images/logo_header1.jpg
alt = Inspired-Evolution.com - Look into the Future
title = Inspired-Evolution.com - Look into the Future
[SoartonNewHeights]
src = images/logo_header2.jpg
alt = Inspired-Evolution.com - Soar to New Heights
title = Inspired-Evolution.com - Soar to New Heights
and the ini and rotate.php file are at the same level as my index.php page as the article indicates to do with the images in a directory called 'images'.
any possible solutions that I might be missing to cause this not to work?
TIA