Bramme Posted November 30, 2007 Share Posted November 30, 2007 Could anybody tell me why this code isn't working: <?php //admin/index.php define('ROOT', $_SERVER['DOCUMENT_ROOT']); require(ROOT.'/libs/Modular.class.php'); $core = new Modular(); $core->template_dir = ROOT.'/admin/templates'; $core->compile_dir = ROOT.'/admin/templates_c'; $uModules = array(); if ($handle = opendir(ROOT.'/admin/mods/') || die("Could not open Modules directory")) { while ($file = readdir($handle) !== false) { if($file != "." && $file != ".." && !is_dir(ROOT.'/admin/mods/'.$file)) { $Module = fopen(ROOT.'/admin/mods/'.$file, 'r'); $modContent = fread($Module, 26); fclose($Module); $uModules[] = $file; } } closedir($handle); } $core->assign('uModules', $uModules); $core->display('index.tpl'); ?> I get two warnings: Warning: readdir(): supplied argument is not a valid Directory resource in /path/index.php on line 14 Warning: closedir(): supplied argument is not a valid Directory resource in /path/index.php on line 25 Line 14 and 25 being the only ones with readdir and closedir in them... Link to comment https://forums.phpfreaks.com/topic/79544-solved-readdirclosedir-warning/ Share on other sites More sharing options...
MadTechie Posted November 30, 2007 Share Posted November 30, 2007 remove the || die("Could not open Modules directory") so change if ($handle = opendir(ROOT.'/admin/mods/') || die("Could not open Modules directory")) { to if ($handle = opendir(ROOT.'/admin/mods/') ) { Link to comment https://forums.phpfreaks.com/topic/79544-solved-readdirclosedir-warning/#findComment-402846 Share on other sites More sharing options...
Bramme Posted November 30, 2007 Author Share Posted November 30, 2007 thanks a bunch, that was stupid of me. Also, $file = opendir(path) !== false had to be changed into false !== ($file = opendir(path)) Link to comment https://forums.phpfreaks.com/topic/79544-solved-readdirclosedir-warning/#findComment-402850 Share on other sites More sharing options...
MadTechie Posted November 30, 2007 Share Posted November 30, 2007 well i would do this while (($file = readdir($handle)) !== false) Link to comment https://forums.phpfreaks.com/topic/79544-solved-readdirclosedir-warning/#findComment-402854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.