I don't think anyone's about to wade through your incredibly obfuscated code. I tried to have a look, and got as far as "while (($file = readdir($banners)) != FALSE)" before thinking "you must be joking".
You also have bits like this: // $l != 0 } // $banner != FALSE How are we supposed to know which bits are live and which bits are commented out? If the problem may be with your code, please make it legible before asking for help. Cheers Jon -----Original Message----- From: Nick selby [mailto:[EMAIL PROTECTED]] Sent: 11 March 2002 10:54 To: [EMAIL PROTECTED] Subject: [PHP] Can no one help with this opendir problem? Hi, I wrote a few days ago and have heard nothing - can ANYONE help with this: I've got a script that is installed on a Solaris machine that is having difficulties, and I'm wondering if anyone can help. The script is trying to access and read files within a directory, pull some at random and put them in a webpage. The path is correct, the directory is set to 755 and I can view the files when I browse in. The script is up and running perfectly on two other servers - one on Red Hat Linux and one on Win2k. The script is this: <?php // This pulls 3 random banners from the appropriate // subdirectory of the images section of the site $i=-1; $banners=opendir($SECTION_SIDEBAR_BANNERS); if ($banners != FALSE) { while (($file = readdir($banners)) != FALSE) if ($file != "." && $file != "..") $banner_list[$i++]=$file; closedir($banners); $l=sizeof($banner_list); if ($l!=0) { for ($i=0;$i<3;$i++) { $ad=$banner_list[rand(0,$l)]; if (empty($ad)) { $i-=1; continue; } $imginfo=getimagesize("$SECTION_SIDEBAR_BANNERS/$ad"); $link=str_replace('.gif','',$ad); $link=str_replace('.jpg','',$ad); $link=str_replace('_','/',$ad); echo " <div class='sidebar-banner-slot'> <a href='$SECTION_URL"."ad-clickthrough.htm?AD_URL=$link'><img src='". $SECTION_SIDEBAR_BANNERS_URL. "/$ad' height='$imginfo[1]' width='$imginfo[0]' border='0' alt='Visit $link' /></a> </div>"; } } // $l != 0 } // $banner != FALSE ?> The problem on the solaris machine is that opendir is getting in to the directory but from that point the server won't let the script read the files. It kicks back the error: Warning: 1 is not a valid Directory resource in /data0/foo.org/members/foo/foo/html/destinations/templates/foo.footer.php on line 20 (Identifying directories are foo'd out) Since it kicks back the "1" and not a false, it seems it's getting access but then not being permitted. Here's something else - the problem is intermittent: sometimes the script can grab the images and others not. Can anyone help? Many thanks in advance. NIck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _____________________________________________________________________ This message has been checked for all known viruses by UUNET delivered through the MessageLabs Virus Control Centre. For further information visit http://www.uk.uu.net/products/security/virus/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php