Grazza Posted January 2, 2013 Share Posted January 2, 2013 I made a simple little code to scan a directory of .doc files and then put all of the information into an sql database but scandir() keeps failing claming the directory doesn't exist. Code is as follows (only the boring sql connection clipped off): $directory = "aa/"; $date = date("m.d.y"); $files = scandir('$directory'); foreach($files as $file) { $fh = fopen($file, 'r'); $content = fread($fh, filesize($file)); fclose($fh); mysql_query("INSERT INTO database (`filename`,`date`,`directory`,`content`) VALUES ('$file','$date','aa','$content')"); } The folder aa is in the same folder as I am running the script from, I have tried using the full path from root with the same results. Error as shown: Warning: scandir($directory): failed to open dir: No such file or directory Any help would be much appreciated. Link to comment https://forums.phpfreaks.com/topic/272615-scandir-retrurning-no-directory-found/ Share on other sites More sharing options...
jazzman1 Posted January 2, 2013 Share Posted January 2, 2013 Rid single quotes of surround $directory. Link to comment https://forums.phpfreaks.com/topic/272615-scandir-retrurning-no-directory-found/#findComment-1402797 Share on other sites More sharing options...
Grazza Posted January 2, 2013 Author Share Posted January 2, 2013 Wow such a silly mistake, works now thanks for the help Link to comment https://forums.phpfreaks.com/topic/272615-scandir-retrurning-no-directory-found/#findComment-1402805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.