View Full Version : PHP Script galleryarray not defined

10-03-2007, 10:59 PM
1) Script Title:
PHP Photo Album Script
2) Script URL (on DD):
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:
to see that the server support PHP, go here:
To see an example of a picture which I believe to be in the correct place, go here:
the getpics.php is in the same directory as the pic above.

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

10-04-2007, 08:34 AM
Try one or both of the below additions (red):

Header("content-type: application/x-javascript");

function returnimages($dirname="./") {
$files = array();
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";


echo "var galleryarray=new Array();" . "\n";

10-04-2007, 09:09 PM
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.

10-05-2007, 03:59 AM
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):

<style type="text/css">

.slideshow{ /*CSS for DIV containing each image*/
float: left;
margin-right: 10px;
margin-bottom: 10px;

.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;

05-03-2008, 04:46 PM
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.

05-04-2008, 12:26 AM
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.

05-04-2008, 03:02 PM
Ok - i figured out the reason for the thumbnails not showing up. - a typo.

05-04-2008, 03:06 PM
That means that you have not set the highlighted variable correctly:

* 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.