PHP sends my site into an endless loop. (Slideshow)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
t0nka
Forum Newbie
Posts: 1
Joined: Thu Jul 24, 2008 3:14 am

PHP sends my site into an endless loop. (Slideshow)

Post by t0nka »

Hi,

I am using the following code to loop through the filenames of a folder and add them into a javascript array for use in my slideshow. This works fine, but once the first loop displaying the images is finished, it sends the site into an endless loop tryinh to download the files..

servername/css/loader-1.png
servername/css/loader-2.png ... etc all the way upto servername/css/loader-11.png

Which are the files that are used by the slideshow.

Code: Select all

<?php
$addarray = array();
$x = 0;
if ($handle = opendir('slideshow')) {
    while (false !== ($file = readdir($handle))) { 
        if ($file != "." && $file != "..") {
            $file_name=substr($file, 0, strpos($file, "."));
                if ( $file_name != "")
                {
                $addarray[$x] = "$file_name.jpg";
                $x = $x + 1;
                }
    }
}
}
closedir($handle); 
?>
 
    <script type="text/javascript">     
    //<![CDATA[
      window.addEvent('domready', function(){
        var data =new Array("<?=implode("\",\"", $addarray); ?>") 
        // Initialize the Slideshow instance
        var myShow = new Slideshow('show', data, { height: 240, hu: 'images/', width: 300 });
      });
    //]]>
    </script>
Coudl someone please have a look at my code an see if they could spot where it is going wrong.

Thanks

Tom
andychamberlainuk
Forum Newbie
Posts: 6
Joined: Mon Jul 28, 2008 7:15 pm

Re: PHP sends my site into an endless loop. (Slideshow)

Post by andychamberlainuk »

i've only had a quick glance but this could be the problem: -

Code: Select all

while (false !== ($file = readdir($handle))) {
it should be: -

Code: Select all

while (false != ($file = readdir($handle))) {
Post Reply