Stumped. Please help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ognar
Forum Newbie
Posts: 2
Joined: Tue May 27, 2003 5:09 pm

Stumped. Please help.

Post by ognar »

I am useing a very simple php script. In fact I will post the whole thing here.

Code: Select all

<?
$album 		=  "Student Work";  				//title of your gallery		//
$columns	=  5;               			//number of photos in a row	//
$thumb_dir 	=  "thumbnails";    			//thumbnails location dir	//
$scriptname	=  "index.php";				//name of this file		//

//----------------------------------------------------------------------//
echo  "<HTML>\n";
echo  "<BODY BACKGROUND='../../background.jpg'>\n";
echo  "<CENTER>\n\n";
$mydirectory=  '.';            
$counter=0;
$nbfiles = 0;
$currfile =   "";
$file&#1111;0] =   "";
$handle=opendir($mydirectory);
if ($home ==   "")
	&#123;echo "<FONT SIZE=5><B>$album</B></FONT><P>\n<TABLE BORDER='0' background='images/rawcanvas.jpg' CELLPADDING='5' CELLSPACING='5'>\n<TR>\n";&#125;
while ($currfile = readdir($handle))  
      	&#123;$extension= strtolower(substr( strrchr( $currfile, "."),1));  
	if ($extension==  "jpg" || $extension==  "jpeg")
      	&#123;$nbfiles++;
      	$currfile = trim($currfile);
      	$file&#1111;$nbfiles] = $currfile;
if ($home ==   "")
	&#123;$currthumbfile =  $thumb_dir .  "/" . $currfile;
	echo "  <TD ALIGN='CENTER' VALIGN='MIDDLE'><A HREF=?home=1&name=$currfile&nr=$nbfiles><IMG BORDER='0' SRC= $currthumbfile></A></TD>\n";
	$counter++;
if ($counter == $columns)
	&#123;$counter= 0;echo"</TR>\n";echo"<TR>\n";&#125;&#125;&#125;&#125;
if ($home ==   "")
	&#123;echo"</TR>\n\n";&#125;
closedir($handle);
if ($home == 1)
	&#123;if ($nr != 1)
	&#123;$prevnumber = $nr - 1;
	echo "<A HREF=?home=1&name=$file&#1111;$prevnumber]&nr=$prevnumber><IMG ALT='Previous' BORDER='0' SRC='../../../prev.gif'></A>\n";&#125;
	echo "<A HREF=$scriptname><IMG ALT='Thumbnails' BORDER='0' SRC='../../../back.gif'></A>\n";
	if ($nr != $nbfiles)
	&#123;$nextnumber = $nr + 1;
	echo "<A HREF=?home=1&name=$file&#1111;$nextnumber]&nr=$nextnumber><IMG ALT='Next' BORDER='0' SRC='../../../next.gif'></A><p>\n";&#125;
 	echo "<TABLE BORDER='0' BGCOLOR='#FFFFFF' CELLPADDING='0' CELLSPACING='0'>\n";
	echo "<TR><TD><IMG ALT=$nr BORDER='0' SRC=$name></TD></TR></TABLE>\n\n";&#125;
?>
</CENTER>
</BODY>
</HTML>
The script creates an image gallery that is viewable using thumbnails and a slide show format.

Here is my problem:

The script runs perfectly on my own server. However when I publish it on my work server I have problems. First to get the script to work at work I have to link directly to the file. That is I have to link to http://www.minisink.com/highschool/artp ... /index.php (must include the index.php) On my personal server http://www.mcassey.com/images/gallery/bacon/art2/ is sufficient (no index.php needed). This isn't a problem per se because it will load the thumbnails page without a problem. However, when I click on a thumbnail (the second part of the script) nothing happens. Does anyone know why this is?

Here is the difference in the two actual links

my server

Code: Select all

http://www.mcassey.com/images/gallery/bacon/art2/?home=1&name=SB1.jpg&nr=1
work server

Code: Select all

http://www.minisink.com/highschool/artpage/images/gallery/bacon/art2/index.php?home=1&name=sb1.jpg&nr=1
Can anyone see a problem? Is it do to a server restriction perhaps? Feel free to check out the pages if it will help make sence of what I am talking about. Right now only the links that I listed are active.

Thanks,

Ognar

P.S. I did not write this script, though I did edit it a bit.
User avatar
oQEDo
Forum Commoner
Posts: 43
Joined: Thu Feb 20, 2003 11:08 am
Location: UK

Post by oQEDo »

It is to do with the default document in your webserver settings.
I cant help you with apache however if you are using IIS then if you open IIS manager, right click properties over your default web site, click on the documents tab and add index.php in the default documents.

This will ensure that if an address is written with / on the end, it will look for the files specified, in your case index.php.

If you are using apache web server, one of the other guys in the forum should be able to help.

RM
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

server

Post by phpScott »

Odds are that it is a server issue.
Your server is probably not set up to allow for index.php pages as default pages in a directory

in the httpd.conf file there is a directive called
DirectoryIndex
that allows you to set what type of pages are allowed to be used as default pages
make sure that index.php is in there.
If you don't have access to the file then I think you are out of luck :(

phpScott
ognar
Forum Newbie
Posts: 2
Joined: Tue May 27, 2003 5:09 pm

Post by ognar »

Thanks for the quick reply. I was hoping I could add something to the script to make it work without having to change server settings. I work at a school and I doubt I will be allowed to make any changes (they are very paranoid). I will ask them to add index.php to the default list, but if they won't is there anything I can do to the script to make it work with out a default?

Thanks again,

Ogs
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

yup

Post by phpScott »

make sure all your code goes to index.php
no short cutting in otherwords :( :x

phpScott
Post Reply