It isn't working

Hey

I got this code where the PHP generates an Javascript array, but it isn’t working. Or I don’t get it.

This is the PHP Getimages.php (It generates an javascript array with filenames)

<?
//PHP SCRIPT: getimages.php
//Header("content-type: application/x-javascript");

//This function gets the file names of all images in the current directory
//and ouputs them as a JavaScript array
function returnimages($dirname="img/gallery/") {
$pattern="(\\.jpg$)|(\\.png$)|(\\.jpeg$)|(\\.gif$)"; //valid image extensions
$files = array();
$curimage=0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){ //if this file is a valid image
//Output it as a JavaScript array element
echo 'fadeimages2['.$curimage.']=["'.$dirname . $file.'"];'."\
";
$curimage++;
}
}

closedir($handle);
}
return($files);
}
echo 'var fadeimages2=new Array();'."\
"; //Define array in JavaScript
returnimages() //Output the array elements containing the image file names


/* THE Array should look like this
var fadeimages2=new Array()
fadeimages[0]=["img/gallery/01_2.jpg"]
fadeimages[1]=["img/gallery/02_2.jpg"]
fadeimages[2]=["img/gallery/03_2.jpg"]
*/
?> 

This is the main page, so the javascript array should be echoed in this script.

<div id="container">
    <div id="slideshow">
    <script type="text/javascript">
<?
require_once('getimages.php'); 
?>
	new fadeshow(fadeimages2, 355, 210, 0, 5000, 0);
    </script>
    </div>

Here’s the page:
http://web.zone.ee/testcss/

But it somewhy doesn’t do what it’s supposed to do i think. Please help.
I don’t see where the problem is. Why doesn’t that javascript slideshow engine show pictures.

its because you have called your array fadeimages2


var fadeimages2=new Array()

but are then callling fadeimages as the array that holds the images


fadeimages[0]=["img/gallery/01_2.jpg"]

Thats the error that stops it working BUT the code above doesnt generate the code on your page. The code above does create the correct fadeimages2 array.

Check the code you are using.

Thanks for pointing out the flaw.
The EeasyPHP server doesn’t show the generated php, thats weird.
BUT, this wasn’t the only thing what was wrong.

Also I put the php in the main page into the script, but how to make the Javascript code get the data generated in the PHP script?