Jump to content

Gallery Script

- - - - -

  • Please log in to reply
2 replies to this topic

#1
so1i

so1i

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 312 posts
Hey Guys,

I have recently been developing a small site for a local folk artist. During developing this, I decided that to make it nice and easy to upload photos (and because for this job it is too much to create a complete CMS for the picture gallery) I would just create a little script that read a directory, and populated the gallery according to the subsequent directories and images it hit.

I wrote this, and it works fine here:

chriskingnet.com

However, when I came to switch over to my clients server, I ran into a bug - which as of yet I just can't figure out!

Bugged site:

hickmanandcassidy.co.uk

I have run phpinfo() on each server.

chriskingnet.com HERE.

hickmanandcassidy.co.uk HERE.

It is a little older than the first, but I'm not sure if that would be the problem (although personally I'm not sure what else it would be - I've made sure all my directories match etc).

Here is the code I am running to populate the galleries:


<?php

							#loop through all directories, use their name to create links, headers and import thumbs

							$count = 0;

							$handle = opendir('./imgs/gallery/');

							while (false !== ($file = readdir($handle)))

							{

								if ($count > 1) {

									echo "<div class='gallery_entry'>";

									echo "<div class='gallery_header'>" . $file . "</div>";

									echo "<div class='gallery_thumb'>";

									echo "<a href='igallery.php?gallery_name=" . $file . "'>";

									echo "<img class='gallery' src='./imgs/gallery/" . $file . "/thumb.png' alt='" . $file . " Thumb' width=148 height=116 />";

									echo "</a>";

									echo "</div>";

									echo "</div>";		

								} else {

									#file is not valid, don't process it

									#first two are not counted, skip them and increment count

									$count++;

								}					

							} 

						?>


I would appreciate any help on this. It might well be that I'm missing something that's right in front of me! Or it might be that I do need to get that update done on the my client's server - just didn't want to do it without definite need to!

(Have attached the .php files including the full html)

Attached Files


My Company - My Homepage - My Twitter - My Google+ - My LinkedIn

"Things don’t have to change the world to be important.” - Steve Jobs

#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
  • Location:New York, NY
You never once mentioned what your bug actually is.

#3
so1i

so1i

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 312 posts

John said:

You never once mentioned what your bug actually is.

Sorry, I should have been clearer.

The two links I provided are supposed to deliver the exact same thing. However as you can see, the first does (provides and album name, and when clicked takes you through to the correct pictures) the second provides an album title of ".." and when clicked takes you to the wrong pictures. It almost seems like I'm just getting the directories wrong (it is producing images from the directory further up in the second link) - but I've checked and I'm not! I'm thinking there must be a logic error somewhere, or maybe something to do with the order directories are in or something?

Thanks,
sol1

[EDIT] Sorry, after all that I've actually managed to spot the bug. Oh well, it probably helped to explain it "out loud". Thanks anyway!
My Company - My Homepage - My Twitter - My Google+ - My LinkedIn

"Things don’t have to change the world to be important.” - Steve Jobs




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users