Question : Random array script not working on web server

Hi all, I've got a script to load a random array and echo it in the relevant place in the HTML. It works on my server at home (I used XXAMMP so not sure what PHP version it is...). However, on my web server (Linux, Streamline.net) it doesn't work: http://www.thedigitalcreative.co.uk/dev/

Here's the code
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
<?php //Loading the images from Flickr
$file_array = array
("<img src='http://farm5.static.flickr.com/4006/4685049939_4da1253f6b_z.jpg' alt='Web design and flash animation for home maintenance specialists the Complete Door Window Company.' /><p>Web design and flash animation for home maintenance specialists the Complete Door Window Company.</p>", 
"<img src='http://farm5.static.flickr.com/4038/4685688826_f5e6e9e249_z.jpg' alt='Web design and Flash animation for celebrity hair stylist Robert Bell.' /><p>Web design and Flash animation for celebrity hair stylist Robert Bell.</p>", 
"<img src='http://farm5.static.flickr.com/4003/4666426166_782dedbe50_z.jpg' alt='Web design and Flash animation for corporate track day experience specialist Atom Experience Ltd.' /><p>Web design and Flash animation for corporate track day experience specialist Atom Experience Ltd.</p>", 
"<img src='http://farm2.static.flickr.com/1277/4665592055_40d85c28c1_z.jpg' alt='Web design for Sisley's Unique Florist.' /><p>Web design for Sisley's Unique Florist.</p>", 
"<img src='http://farm2.static.flickr.com/1266/4665588911_01a07b6fe1_z.jpg' alt='Web design for custom electric guitar builders Wynne Guitars.' /><p>Web design for custom electric guitar builders Wynne Guitars.</p>", 
"<img src='http://farm5.static.flickr.com/4076/4748358149_38e3991eff_z.jpg' alt='Web design for financial legal experts AIMS International. I like designing for start-up businesses though I wish I'd had control over the logo colours (the turquoise is rather saturated and fluorescent). The site was built by Object Source (www.object-source.com).' /><p>Web design for financial legal experts AIMS International. I like designing for start-up businesses though I wish I'd had control over the logo colours (the turquoise is rather saturated and fluorescent). The site was built by <a href='http://www.object-source.com' title='Object Source Website'>Object Source</a>.</p>"); 
$total = count($file_array); 
$random = (mt_rand()%$total); 
$file = "$file_array[$random]"; 
?>


Any help would be greatly appreciated, thanks!

Answer : Random array script not working on web server

And.. if you are getting the same value every time, this may be due to older version of PHP. You have to use mt_srand(); before mt_rand() in that case
http://www.php.net/manual/en/function.mt-srand.php
Random Solutions  
 
programming4us programming4us