Results 1 to 3 of 3

Thread: Swiss Army Knife not displaying

  1. #1
    Join Date
    Mar 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Swiss Army Knife not displaying

    1) Script Title: Swiss Army Knife with php array

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...army/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

  2. #2
    Join Date
    Mar 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, this (highlighted):

    Code:
    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
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •