note 55064 added to function.is-dir

From: Date: Sun, 24 Jul 2005 11:53:05 +0000
Subject: note 55064 added to function.is-dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-92376@lists.php.net to get a copy of this message
Actually I was trying to read a folder and get a filename out of it. There is no problem with the following code when it is ran through browser, but when I include the file in another file, the code was not actually working the way it should work, If statement goes wrong way. I dont know how to fix it. And else statement is executed allways. CODE <?php include "login_check.php"; echo "$valid_user"; $dir = "$valid_user"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { echo "directory opened"; $index=0; while (($file = readdir($dh)) !== false) { //echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; //echo "$file"; $img[$index] = "$file"; $index=$index+1; } //echo "$img[2]"; echo "<img border=\"0\" height=\"120\" hspace=\"3\" src=\"$valid_user/$img[2]\" vspace=\"3\" width=\"89\">"; closedir($dh); } } else { echo "<img border=\"0\" height=\"120\" hspace=\"3\" src=\"../nophoto1.jpg\" vspace=\"3\" width=\"89\">"; } ?> the login_chek.php file <?php session_start(); if (session_is_registered("valid_user")) { session_save_path("$id.txt"); } else { header ("Location: index.php"); } ?> I THINK THE is_dir FUNCTION IS NOT WORKING PROPERLy. I HAVE ALSO USED file_exists function. SO IF ANYONE CAN TELL ME WHATS GOING ON, IT CAN HELP ME A LOT Thankyou in advance. ---- Manual Page -- http://www.php.net/manual/en/function.is-dir.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55064 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55064&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55064&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55064&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55064&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55064&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55064&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55064&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92376) next »