muckv Posted October 21, 2008 Share Posted October 21, 2008 function make_thumb_dir($path){ $resource_path = opendir($path) or die('Dir openen gaat niet'); while (($filename = readdir($resource_path)) != false) { if (is_dir($filename) && $filename =! '.'&& $filename =! '..') { $img = get_images_in_dir($filename); } } closedir($resource_path); } I never get through to $img = get_images_in_dir($filename); He checks the $filenames in the if but never executes $img = get_images_in_dir($filename); and the $filename is a directory? Could you guys help me out? Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted October 21, 2008 Share Posted October 21, 2008 see whether the path assigned to $resource_path is valid and whether it contains files other than '.' and '..' Quote Link to comment Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 it is valid when I debug I see the correct $filenames in the if taking turns in the while Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted October 21, 2008 Share Posted October 21, 2008 ho! change this is_dir($filename) to is_file($filename). you are checking for files right! Quote Link to comment Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 No i'm checking for dirs Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted October 21, 2008 Share Posted October 21, 2008 can you change this and try(the comparison operator part) $filename =! '.'&& $filename =! '..' to $filename != '.'&& $filename != '..' Quote Link to comment Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 nope Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted October 21, 2008 Share Posted October 21, 2008 the comparison operator you have used is wrong. the below code is working for me if (is_dir($filename) && $filename != '.'&& $filename != '..') { Quote Link to comment Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 Well yeah, it works for me too, but he does'nt execute the next line. So it goe like this $filename = string '.' so do'nt go into the if NEXT $filename = string '..' so do'nt go into the if NEXT $filename = string 'bram' since bram is a directory he should proceed with the code in the if statement right? well it doesn't instead it goes to the next $filename NEXT $filename = string 'jan' same as above NEXT $filename = string 'suzy' same as above, end of function NEXT Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted October 21, 2008 Share Posted October 21, 2008 can you post here the function get_images_in_dir Quote Link to comment Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 function get_images_in_dir($validpath) { $files = scandir($validpath); for($i = 0;$i < sizeof($files);$i++) { $ext = substr($files[$i], strrpos($files[$i], '.') + 1); if(check_extensie($ext)){ return $files[$i]; } } } Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted October 21, 2008 Share Posted October 21, 2008 see whether this function is returning anything. Quote Link to comment Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 no, but it is never called upon Quote Link to comment Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 forget all the code before and look at this function check_for_dir($path){ $resource_path = opendir($path) or die('Dir openen gaat niet'); while (($filename = readdir($resource_path)) != false) { if (is_dir($filename)) { echo $filename; } } closedir($resource_path); } tough there are 3 dirs in the given path the output is ... he evaluates the 3 dirs as NO dirs in is_dir() Quote Link to comment Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 I had to prepend the working dir. function check_for_dir($path){ $resource_path = opendir($path) or die('Dir openen gaat niet'); while (($filename = readdir($resource_path)) != false) { if (is_dir('./main'$filename)) { echo $filename; } } closedir($resource_path); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.