# Help me with some php

**URL:** <https://forum.kirupa.com/t/help-me-with-some-php/64073>\
**Category:** Uncategorized\
**Created:** [September 13, 2004, 3:32am UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073 "2004-09-13T03:32:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)\
**Post date:** [September 13, 2004, 3:32am UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/1 "2004-09-13T03:32:08Z")

</div>

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:

```php

<?
$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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 13, 2004, 4:05am UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/2 "2004-09-13T04:05:38Z")

</div>

Maybe change this:

```php
$handle = opendir(".");

```

to:

```php
$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).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 13, 2004, 8:30am UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/3 "2004-09-13T08:30:16Z")

</div>

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

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

```

Sintax :mu:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 13, 2004, 9:02am UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/4 "2004-09-13T09:02:05Z")

</div>

```php

$handle = opendir("./"); 

```

or

```php

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

```

May also work.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 13, 2004, 2:07pm UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/5 "2004-09-13T14:07:39Z")

</div>

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

Thanks everyone -

:hr:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 13, 2004, 4:48pm UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/6 "2004-09-13T16:48:39Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 13, 2004, 5:01pm UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/7 "2004-09-13T17:01:16Z")

</div>

What do you mean ‘invalid XML’?

:hr:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 13, 2004, 5:11pm UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/8 "2004-09-13T17:11:00Z")

</div>

> [@lunatic](#):
>
> 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.

```auto

 <?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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 13, 2004, 6:24pm UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/9 "2004-09-13T18:24:26Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 18, 2004, 7:26pm UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/10 "2004-09-18T19:26:00Z")

</div>

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:

```php
<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/](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:

```auto
<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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 19, 2004, 7:41am UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/11 "2004-09-19T07:41:20Z")

</div>

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

```php

$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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 1:08am UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/12 "2004-09-20T01:08:53Z")

</div>

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](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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 11:42pm UTC](https://forum.kirupa.com/t/help-me-with-some-php/64073/13 "2004-09-20T23:42:32Z")

</div>

Anyone? 😏
