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? Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/ 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 '..' Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670708 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 Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670709 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! Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670710 Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 No i'm checking for dirs Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670712 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 != '..' Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670713 Share on other sites More sharing options...
muckv Posted October 21, 2008 Author Share Posted October 21, 2008 nope Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670715 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 != '..') { Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670718 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 Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670721 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 Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670722 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]; } } } Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670745 Share on other sites More sharing options...
ranjuvs Posted October 21, 2008 Share Posted October 21, 2008 see whether this function is returning anything. Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670748 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 Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670750 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() Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670783 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); } Link to comment https://forums.phpfreaks.com/topic/129380-solved-unreachable-statement/#findComment-670797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.