Jump to content


Photo

Counting Files in a directory


  • Please log in to reply
26 replies to this topic

#21 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 21 May 2006 - 06:47 PM

well i was going to eventually get to that. i actually started posting about it such and all but i did a preview and saw you beat me to it so i just ditched the post except for the cheat [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]

after all is said and done, just do

$count = $count - 2;

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#22 QuadVods

QuadVods
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 21 May 2006 - 06:52 PM

Fantastic! Thanks again everyone [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

#23 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 21 May 2006 - 06:53 PM

Well, you could even cut the if statement to just this:

if (is_file($file)) {
$count++;
}

Please show us the filenames/directories of what you actually have in that '1' directory now.


FYI:

Short cut to subtracting is: $count -= 2;



#24 QuadVods

QuadVods
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 21 May 2006 - 07:05 PM

.

#25 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 21 May 2006 - 07:07 PM

We forgot to specify the full path to the file on the is_file() function. The readdir() doesn't return a pull path and the filename, but rather just the filename.

if ((is_file($dir . $file)) && ($file != '.') && ($file != '..')) {
$count++;
}

Please try that and get back to us.

#26 QuadVods

QuadVods
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 21 May 2006 - 07:13 PM

[!--quoteo(post=375856:date=May 21 2006, 08:07 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 21 2006, 08:07 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
We forgot to specify the full path to the file on the is_file() function. The readdir() doesn't return a pull path and the filename, but rather just the filename.

if ((is_file($dir . $file)) && ($file != '.') && ($file != '..')) {
$count++;
}

Please try that and get back to us.
[/quote]

Parse error:....

#27 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 21 May 2006 - 07:18 PM

[!--quoteo(post=375857:date=May 21 2006, 12:13 PM:name=QuadVods)--][div class=\'quotetop\']QUOTE(QuadVods @ May 21 2006, 12:13 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Parse error:....
[/quote]
There's no parse error in that code. It's somewhere else.

Parse Errors are caused by human error. Check on the line of the error, but usually one to many lines before it, for missing closing tags (i.e. ", ), }, ;, etc.).

Here's a list of what those PHP tokens seen in error messages mean:
[a href=\"http://us2.php.net/manual/en/tokens.php#tokens\" target=\"_blank\"]http://us2.php.net/manual/en/tokens.php#tokens[/a]







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users