Forum Moderators: coopster

Message Too Old, No Replies

Automated Image Gallery Problem.

         

Tomness

2:01 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



I have this automated image gallery script that a friend of mine wrote for me; however, it's unable to be called.

My website is all bought together using php, and calling so, to have these image galleries could be a problem.

Does anyone have an alternative to what I have, or does anyone have a soloution to enable me to call it.

Here's the code:

?
$NAMEFILE = "index.php"; //This files name.

$dir = opendir("."); //Replace the dot with ./yourfolder or leave it as it is.
while ($file = readdir($dir)) {
if ($file!= "." && $file!= ".." && $file!= "$NAMEFILE") {
$time = filemtime("$file");
$data[$time] = "<a href=\"$file\" target=\"new\"><img src=\"$file\" width=\"150\" height=\"125\"></a>
";
}}

krsort($data);
while(list($k,$v) = each($data)) { echo $v; }
clearstatcache();

echo "";

?>

coopster

1:38 am on Aug 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Could you offer some more explanation on where you are stuck here, Tomness?

Tomness

9:48 am on Aug 4, 2005 (gmt 0)

10+ Year Member



I don't know to be honest. I would like to, but I can't think of how I could be any more clear...

I use an include code <? include('page.html'');?> to call other pages. However, this script for an image gallery doesn't work when I call it with an include.

Why?

bzikofski

9:57 am on Aug 4, 2005 (gmt 0)

10+ Year Member



"doesn't work" sounds imprecise. show us the error here that you're getting.

and first of all make sure that the directory that script is reading is allowed to be read.

cheers

Tomness

1:09 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



It is allowed to be read.

It's not giving me an error message no more. However, it has decided to call every image from my route directory into the gallery rather than that from the folder. =¦

The url to the gallery is

index.php?get=***/photography/other/test/index.php

I want all the images from the 'test' folder to appear. However, all the images from the route directory are.

bzikofski

1:25 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



i think you should post the complete code of the page that is doing the trick along with absolute paths of the scripts.

you can't copy url's here i guess.. except this way [test.com ]

yeah brace them within pseudo-code (url in square brackets)

Tomness

3:05 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



i think you should post the complete code of the page that is doing the trick along with absolute paths of the scripts.

The page html is as follows.

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Website Title</title>

<meta tags>

<link rel="stylesheet" type="text/css" href="stylesheet.css">
<link rel="shortcut icon" href="favicon.ico">

</head>

<body class=gbody>

<div class=container>

<div class=banner><img src="banner.jpg"></div>

<div class=navigation>
<? include('navigation.html');?>
</div>

<p>

<div class=content>

<?php
$pagina = $_GET[get];

$StandaardMap = "";

$StandaardExtensie = ".php";

$StandaardBestand = "main.php";

$FoutBestand = "error.html";

if(!$pagina) { include("$StandaardMap$StandaardBestand"); }
elseif(strstr($pagina,"1") ¦¦ strstr($pagina,"0") ¦¦ strstr($pagina,"2")) { include("$StandaardMap$FoutBestand"); }
elseif(file_exists("$StandaardMap$pagina$StandaardExtensie")) { include("$StandaardMap$pagina$StandaardExtensie"); }
elseif(file_exists("$StandaardMap$pagina")) { include("$StandaardMap$pagina"); }
else { include("$StandaardMap$FoutBestand"); }
?>

</div>

<p>

<div class=navigation>
<? include('footer.php');?>
</div>

</div>
</body>

</html>

There. The image gallery code is posted in the original post of this thread.

bzikofski

3:26 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



you didnt post any paths but nevermind i see where the problem might be:

$dir = opendir("."); //Replace the dot with ./yourfolder or leave it as it is.

did you replace the dot?
replace it with absolute path to the folder where the pictures reside.

i hope it helps

Tomness

7:19 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



you didnt post any paths but nevermind i see where the problem might be

What do you mean, 'paths'?

However, I tried your method, and I got the page but no images. Instead, just an error message:


Warning: opendir(/mrtom/photography/other/test): failed to open dir: No such file or directory in /home2/mrtom/public_html/mrtom/photography/other/test/index.php on line 15

Warning: readdir(): supplied argument is not a valid Directory resource in /home2/mrtom/public_html/mrtom/photography/other/test/index.php on line 16

Warning: krsort() expects parameter 1 to be array, null given in /home2/mrtom/public_html/mrtom/photography/other/test/index.php on line 23

Warning: Variable passed to each() is not an array or object in /home2/mrtom/public_html/mrtom/photography/other/test/index.php on line 24

In the code, I changed the . to the following:

$dir = opendir("/mrtom/photography/other/test");
while ($file = readdir($dir)) {

bzikofski

10:29 am on Aug 8, 2005 (gmt 0)

10+ Year Member



a "path" is a directory where a particular script resides. an "absolute" one should contain complete structure from the top (root) to the bottom (script). this is what i mean and it's really basic knowledge - if you don't get it you need to get some reading.

when using opendir() you should specify an ABSOLUTE path - you specified a relative to /home2/ that's why you got the first error. it should be "/home2/mrtom/photography/other/test"

read this:
[php.net...]
and correct your script.

Tomness

8:26 pm on Aug 8, 2005 (gmt 0)

10+ Year Member



Thank you very much. I will re-post when / if I have any more trouble.