Warning: fclose() [function.fclose]: 5 is not a valid stream resource in C:\xampp\htdocs\baoky\auto.php on line 324 Can i ask if fclose return not a valid stream, can i execute some command and not leave it there with the warning. How do i do the if else, cause i am running a script which will check whether a directory contains some files... then if it contain, it will run certain, else if nothing it return this not a valid stream resource which i want is if it contain nothing , it will exec($command,$output,$string) Anyone can help me with sample code on how to get it going, thanks!!