# Simple script wont work with PHP4 (but works with PHP5)

**URL:** <https://forum.kirupa.com/t/simple-script-wont-work-with-php4-but-works-with-php5/166510>\
**Category:** programming\
**Created:** [October 20, 2005, 3:38pm UTC](https://forum.kirupa.com/t/simple-script-wont-work-with-php4-but-works-with-php5/166510 "2005-10-20T15:38:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henxon](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@Henxon](https://forum.kirupa.com/u/Henxon)\
**Post date:** [October 20, 2005, 3:38pm UTC](https://forum.kirupa.com/t/simple-script-wont-work-with-php4-but-works-with-php5/166510/1 "2005-10-20T15:38:45Z")

</div>

Hello

I have developed a dynamic image viewer with PHP and Flash on my computer, running PHP5 on my local apache server. Now that I have transferred the site to a webhotel, running PHP4.x, the PHP wont return an array with the images anymore. Here is the code:

```php
<?php
$dir = opendir("controlroom/");
while ($file = readdir($dir)) {
if ($file=="." or $file=="..") continue;
$string.= $file;
$string.= ", ";
}
echo "imgList=".$string;
?> 

```

Running the php-file on my own server (PHP5), this is what I get in return:

> imgList=img1.jpg,img2.jpg,

That make’s my image gallery properly load the array, but when I run the same PHP file on the webhotel (PHP4.x), this is the return:

> **Notice** : Undefined variable: string in **C:\Inetpub\wwwroot\projekt\sidor\web\_site\img\studio.php** on line **5**  
> imgList=img1.jpg,img2.jpg,

The array is now _undefined_. Won’t my code work with PHP4, or can there be anything else that’s wrong?

This is the flash code for taking in the array, if it can help…  
[AS]lvStudio = new LoadVars();

```
lvStudio.load("./img/studio.php");
lvStudio.onLoad = function(success) {
    if (success) {
        studioArray = this.imgList.split(", ");

```

}  
//else {trace(“could not load file”) }  
}[/AS]

/henrik, sweden
