Click to See Complete Forum and Search --> : Count


comptech520
05-16-2005, 08:35 PM
Hi, I am using
<?php
<?php
$numFiles = 0;
if ($handle = opendir('http://esctonline.com/photoweb/test/123104/')) { # '.' = current dir, change to desired dir
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$numFiles++;
}
}
closedir($handle);
}
echo "<p>There are $numFiles photos available to view</p>\n";
?>

to count the number of photos in a directory. Is still says that there are 0 photos available. Can you help? Thanks

NogDog
05-16-2005, 10:18 PM
Try this for debugging:

$numFiles = 0;
if ($handle = opendir('http://esctonline.com/photoweb/test/123104/')) { # '.' = current dir, change to desired dir
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$numFiles++;
}
}
closedir($handle);
echo "<p>There are $numFiles photos available to view</p>\n";
}
else {
echo "<p>ERROR: opendir() failed.</p>\n"
}

JerryJr
05-16-2005, 10:54 PM
Try changing this line:

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

to this

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