Results 1 to 8 of 8

Thread: PHP Script galleryarray not defined

  1. #1
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Script galleryarray not defined

    1) Script Title:
    PHP Photo Album Script
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...photoalbum.htm
    3) Describe problem:
    When I add the photo album script and open the page in a browser, nothing appears. Instead, I get the error, "galleryarray not defined" on lines 96 and 148. I checked the path and it is ok. I searched through the forums for this issue, but none of the answers there fixed my problem.
    To see an example, go here:
    http://72.20.139.220/test/123.html
    to see that the server support PHP, go here:
    http://72.20.139.220/test/test.php
    To see an example of a picture which I believe to be in the correct place, go here:
    http://72.20.139.220/gallery/1.jpg
    the getpics.php is in the same directory as the pic above.

    I'm sure I missed something stupid. Thanks in advance

  2. #2
    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

    Try one or both of the below additions (red):

    Code:
    <?php
    Header("content-type: application/x-javascript");
    
    function returnimages($dirname="./") {
       $pattern="\.(jpg|jpeg|png|gif|bmp)$";
       $files = array();
       $curimage=0;
       if($handle = opendir($dirname)) {
           while(false !== ($file = readdir($handle))){
                   if(eregi($pattern, $file)){
    		 $filedate=date ("M d, Y H:i:s", filemtime($file));
                     echo 'galleryarray[' . $curimage .']=["' . $file . '", "'.$filedate.'"];' . "\n";
                     $curimage++;
                   }
           }
    
           closedir($handle);
       }
       return($files);
    }
    
    echo "var galleryarray=new Array();" . "\n";
    returnimages();
    ?>
    - John
    ________________________

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

  3. #3
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks! Made both changes and it worked great!
    Is there any way to have the thumbnails not distort the images? Some of the images are wide and they get distorted when resized.

  4. #4
    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

    There are different things that can be done with the style. What exactly that you do will depend upon the images, you can also follow the script's instructions for creating a thumbnail directory. This css seemed to work fairly well with the current images (just a few changes from what you had):

    Code:
    <style type="text/css">
    
    .slideshow{ /*CSS for DIV containing each image*/
    float: left;
    margin-right: 10px;
    margin-bottom: 10px;
    min-width:107px;
    }
    
    .slideshow img{ /*CSS for each image tag*/
    border: 0;
    height: 106px;
    }
    
    #navlinks{ /*CSS for DIV containing the navigational links*/
    width: 400px;
    }
    
    #navlinks a{ /*CSS for each navigational link*/
    margin-right: 8px;
    margin-bottom: 3px;
    font-size: 110%;
    }
    
    #navlinks a.current{ /*CSS for currently selected navigational link*/
    background-color: yellow;
    }
    </style>
    - John
    ________________________

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

  5. #5
    Join Date
    May 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am getting the same error -galleryarray not defined. I made changes to the getpics.php file as outlined above but it made to difference.

    the site is www.raleighrss.com/Photos/imagepage.php

    Any assistance would be greatly appreciated.

  6. #6
    Join Date
    May 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php photo album

    update - I recopied the code and the undefined array error went away. The page now shows the places for the photos and will display once clicked on, just no thumbnails.

  7. #7
    Join Date
    May 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok - i figured out the reason for the thumbnails not showing up. - a typo.

  8. #8
    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

    That means that you have not set the highlighted variable correctly:

    Code:
    /***********************************************
    * PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    
    var dimension="3x2" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
    var imagepath="http://www.mysite.com/gallery/" //Absolute path to image directory. Include trailing slash (/)
    var href_target="new" //Enter target attribute of links, if applicable
    
    //Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
    var popupsetting=[1, "width=500px, height=400px, scrollbars, resizable"]
    
    //Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
    var descriptionprefix=[1, "Photo "]
    
    //Sort images by date? ("asc", "desc", or "")
    //"desc" for example causes the newest images to show up first in the gallery
    //"" disables this feature, so images are sorted by file name (default)
    var gsortorder="desc"
    
    //By default, each image hyperlinks to itself.
    //However, if you wish them to link to larger versions of themselves
    //Specify the directory in which the larger images are located
    //The file names of these large images should mirror those of the original
    //Enter a blank string ("") to disable this option
    var targetlinkdir="http://www.mysite.com/largegallery/"
    It could (in many cases) be set the same as your targetlinkdir, however the advanced method (preferred for bandwidth purposes, and at times appearance's sake) is to point it to a directory of thumbnail images, one of each of which has the same name as each of your larger images. These thumbnails will then be used as the trigger images. If you go with the first choice (using the targetlinkdir value) the browser will attempt to scale the larger images to act as your 'thumbnail' triggers.
    - 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
  •