Invalid Directory Resource?

From: Date: Mon, 10 Jul 2000 04:17:12 +0000
Subject: Invalid Directory Resource?
Groups: php.dev 
Request: Send a blank email to php-dev+get-23987@lists.php.net to get a copy of this message
I'm trying to open a directory and print out all files that have $id in the filename, but when I use the code below, I get "1 is not a Valid Resource" on the readdir line. The directory exists, and I think I'm calling it correctly. The way the site works is it's one file that has a ?id=whatever in the address. whatever is then looked up in a database and corresponding data is pumped out through a template. It seems that sometimes when the page is reloaded (with or without a different id,) sometimes the directory resource id doesn't change, and then I get the invalid warning. So, is there a way to somehow reset the directory resource id? Or maybe have it get a new one each time? (reliably) Thanks in advance, John Fuetsch # Load Directory Into Array $dir = "images/thumbs"; $handle=opendir($dir); while ($file = readdir($handle)) { if(strstr($file,$id)) { $images[count($images)] = $file; } } # Clean up and sort closedir($handle); sort($images);

« previous php.dev (#23987) next »