note 55063 rejected from function.is-dir by betz

From: Date: Tue, 13 Sep 2005 13:03:02 +0000
Subject: note 55063 rejected from function.is-dir by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-95115@lists.php.net to get a copy of this message
Note Submitter: jeswanth at gmail dot com ---- 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.

« previous php.notes (#95115) next »