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. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted January 2, 2013 Share Posted January 2, 2013 Rid single quotes of surround $directory. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.