Jump to content

QuadVods

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by QuadVods

  1. [!--quoteo(post=375856:date=May 21 2006, 08:07 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 21 2006, 08:07 PM) [snapback]375856[/snapback][/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:....
  2. Fantastic! Thanks again everyone [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  3. @toplay: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]if ((is_file($file)) && ($file != '.') && ($file != '..')) { $count++; }[/quote] Still gives 2 more files than I have. I'm up for the ghetto method if you don't want to worry about it.. help with that or a true fix would be great.
  4. [!--quoteo(post=375841:date=May 21 2006, 07:35 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 21 2006, 07:35 PM) [snapback]375841[/snapback][/div][div class=\'quotemain\'][!--quotec--] umm, well then shouldn't it now be returning the count, including . and .. ? [/quote] Well the counter is 2 out of the actual figure.. but thats close enough for me! If you know why that is.. that would be super. Code I have now: [code] //get path of directory $dir = $_SERVER['DOCUMENT_ROOT'] . '/1/'; //open a handle to the directory $handle = opendir($dir); if (!$handle) {     echo $dir, ' could not be opened.';     exit; } //intitialize our counter $count = 0; //loop through the directory while (false !== ($file = readdir($handle))) {     //evaluate each entry, removing the . & .. entries   if ((is_file($file)) && ($file !== '.') && ($file !== '..')) {     // $count++;   } $count++; } echo $count;[/code]
  5. [!--quoteo(post=375834:date=May 21 2006, 07:25 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 21 2006, 07:25 PM) [snapback]375834[/snapback][/div][div class=\'quotemain\'][!--quotec--] humor me. move $count++ outside the if statement like so: [code] //intitialize our counter $count = 0; //loop through the directory while (false !== ($file = readdir($handle))) {     //evaluate each entry, removing the . & .. entries   if ((is_file($file)) && ($file !== '.') && ($file !== '..')) {     // $count++;   } $count++; } echo $count; [/code] [/quote] [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] It works, It works! [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] Thanks very much both of you!
  6. [!--quoteo(post=375824:date=May 21 2006, 06:59 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 21 2006, 06:59 PM) [snapback]375824[/snapback][/div][div class=\'quotemain\'][!--quotec--] The last code you posted didn't include other stuff I've recommended you do. So, display the $dir value, include the is_dir(), check the $handle variable, and put echo's in the while loop to help yourself debug this problem. Good luck. [/quote] The last code was the original script before I edited it. So this is what I have to far: [code]//get path of directory $dir = $_SERVER['DOCUMENT_ROOT'] . '/1/'; // /kunden/homepages/23/d163968312/htdocs/upload/1/ if (!is_dir($dir)) {     echo $dir, ' is not a directory or is not found.';     exit; } //open a handle to the directory $handle = opendir($dir); if (!$handle) {     echo $dir, ' could not be opened.';     exit; } //intitialize our counter $count = 0; //loop through the directory while (false !== ($file = readdir($handle))) {     //evaluate each entry, removing the . & .. entries   if ((is_file($file)) && ($file !== '.') && ($file !== '..')) {     $count++;   } } echo $count;[/code] It still just retuns the '0'.
  7. [!--quoteo(post=375819:date=May 21 2006, 06:49 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 21 2006, 06:49 PM) [snapback]375819[/snapback][/div][div class=\'quotemain\'][!--quotec--] Well, this should work (as I posted before): $dir = $_SERVER['DOCUMENT_ROOT'] . '/1/'; // /kunden/homepages/23/d163968312/htdocs/upload/1/ Don't use 'php_self' because you're script is probably not running in the '/1/' directory. [/quote] It still just says 0... There are 8 files in the directory at this moment. And yes - the script isnt in the 1 directory.
  8. edit Does that help? Thanks for the other info - i'll check that out
  9. Nope - I tried both the edits you mention, I just ge a '0'. I've got shared hosting, so I cant change any php settings. It is worth mentioning that the original script works and counts the files in the directory it is placed in... [code] //get path of directory containing this script $dir = $_SERVER['DOCUMENT_ROOT'].dirname($PHP_SELF); //open a handle to the directory $handle = opendir($dir); //intitialize our counter $count = 0; //loop through the directory while (false !== ($file = readdir($handle))) {     //evaluate each entry, removing the . & .. entries   if (is_file($file) && $file !== '.' && $file !== '..') {     $count++;   } } echo $count; [/code]
  10. Hi, I'm using this script to count the number of files in a directory (e.g. I want to display: '10 Files hosted') The problem is that this code is returning '0' as the count, which is wrong. The index page in the root will have the counter on (www.domain.com) the directory with the files in is www.domain.com/1 [code] //get path of directory $dir = ("/1/"); //open a handle to the directory $handle = opendir($dir); //intitialize our counter $count = 0; //loop through the directory while (false !== ($file = readdir($handle))) {     //evaluate each entry, removing the . & .. entries   if (is_file($file) && $file !== '.' && $file !== '..') {     $count++;   } } echo $count; [/code] Any help would be much appreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.