Help me with some php

Hi all,

Let me preface by saying I know NO php so this will probably be an easy question but I’m just a php-moron so don’t laugh at me please.

Okay, I have a cool photo stack fla that reads an xml and a php file to load the photos. In the original file the photos were all on the same directory level as the swf, php, and xml files. I altered it to have the photos in a directory called “pics” which the xml has no trouble reading. Everything works great when tested on my machine but when I load everything up onto my server the only photo being read is one that is on the same level as the files, not the subdirectory of “pics”. I’m taking a big guess here thinking that it’s something to do with the php file. Here is the code it contains:


<?
$xml = '<?xml version="1.0"?'.'>';
$handle = opendir(".");
while ( ($file=readdir($handle)) !== false ) {
	if ( !is_dir($file) ){
		$pic = @getimagesize($file);
		if($pic != false && $pic[2] == 2){
			$xml .= '<img src="'.$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';
		}
	}
}
echo $xml;
?>

If this isn’t it I’ll try something else but if it is it would make my day if someone could point out what I’m missing.

:hr:

Maybe change this:

$handle = opendir(".");

to:

$handle = opendir("http://www.myfulldomain.com/pics/");

On my site I set a variable ‘domain’ and give it the full path of the domain I’m using. It helps when you need to use the domain often (header values etc).

Or you can use this code (i think), either way propably produces the same result…

$handle = opendir($_SERVER["DOCUMENT_ROOT"]."/pics/");

Sintax :mu:


$handle = opendir("./"); 

or


$handle = opendir("./pics/");

May also work.

Sweet! I will give them all a try and let you know!

Thanks everyone -

:hr:

Also, that’s invalid XML - if Flash is refusing to read it, that’d be why :slight_smile:

http://www.w3.org/TR/2004/REC-xml-20040204/#sec-well-formed

What do you mean ‘invalid XML’?

:hr:

Well, XML documents must have a root element/node, as in there must be one element that contains all other elements.


 <?xml version="1.1"?>
 <!-- xml prolog, optional -->
 <foo>
    <foo2 id="f"></foo2>
    <foo2 id="b"></foo2>
    <foo2 id="h"></foo2>
 </foo>
 <!-- invalid: -->
 <foo2 id="f"></foo2>
 <foo2 id="b"></foo2>
 <foo2 id="g"></foo2>
 

From what I’ve read of your code (I might be reading it totally wrong tho) you’re not outputting the first node :slight_smile:

Well, what’s posted above is just the php file. I’ll have to take a closer look at the xml file but I believe it to be valid. What in the php code makes you think the xml code isn’t right?

Thanks - I’m trying to learn from all this.

:hr:

Okay I am still having trouble with these files. I added the pics directory to the img src tag in the xml file so it looks like this:

<img src="pics\berklee.jpg" width="360" height="228" />

but it is still only looking at any img that is in the same level as the php and xml file. You can see it not working here:

http://www.marysuetobin.com/

Click on ‘pics’ in the menu and you’ll see it shows the image that is on the splash page, which is the only jpg in the main directory.

I did notice however that the example file came with an html index page that reads:

<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
	<title>Flash Photo Stack</title>
</head>
<body style="margin:0px">
	<object id="flashmovie" type="application/x-shockwave-flash" data="gallery.swf" width="100%" height="100%">
		<param name="movie" value="gallery.swf" />
		<param name="FlashVars" value="<? if(isset($_GET['image'])) echo "topimage=".$_GET['image'] ?>" />
	</object>
</body>
</html>

Does any of the above code have anything to do with this problem?

Any ideas?

:hair:

You need to change the opendir statement as well. So keep your change to the img src statement and change the PHP to


$handle = opendir("pics");

Right now the PHP still reads the current directory ("."). That’s why you get the files in the current directory.

Btw., you may want to change the backslash in your img src tag to a forward slash, so it becomes pics/berklee.jpg

Thanks for catching that backslash - I did change it.

But the gallery is still not working. It shows nothing. I even tried adding a preloader to see if that was the problem - just the simple one from kirupa:

http://www.kirupa.com/developer/mx/preloader.htm

But all it does is flash “[]type function[]” when you click the button and then nothing?

This doesn’t seem like it should be so hard! Argh! What am I doing wrong?

Thanks for any help.

:hair:

Anyone? :smirk: