PDA

View Full Version : Swiss Army Knife not displaying



ijyoung
02-23-2009, 10:00 AM
1) Script Title: Swiss Army Knife with php array

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/swissarmy/index.htm

3) Describe problem:

I have had this script working for some while now, but on miving to a different domain with same host, I cannot get the slides to work.
php script to pull out the array is:
<?
function returnimages($dirname="./../pics/") {
$pattern="\.(jpg|jpeg|png|gif|bmp)$";
$files = array();
$curimage=0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
echo 'slides[' . $curimage .']=["' . $dirname . $file . '", "", ""];' . "\n";
$curimage++;
}
}

closedir($handle);
}
return($files);
}

echo "var slides=new Array();" . "\n";
returnimages();
?>

Both the scripts are pulled from off-page includes.

On the page there is no image but message "Slide Show Image"

I have tried every which way with this and get nothing yet on my original website with the same code it is working fine.

Any clue?

Cheers

Ian

ijyoung
02-23-2009, 11:33 AM
Hi Folks

Have it sorted. The script needs to sit in the root otherwise the javascript doesn't recognise the array.

How odd. But at least know why it wasn't working.

Cheers

Ian

jscheuer1
02-23-2009, 04:06 PM
Well, this (highlighted):



unction returnimages($dirname="./../pics/") {

is your path to the images. It must be valid for both the PHP code (wherever it is run from) and for the page that uses the images. That path looks to me to mean (breaking it down):

./ - this folder

./../ - this folder's parent folder

./../pics/ - this folder's parent folder's child folder named pics