daxguy Posted December 19, 2010 Share Posted December 19, 2010 I was trying to access my files in a folder i have to further manipulate them but i am havin the following error Warning: opendir(C: mpp\htdocs\j) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\re_name.php on line 3 Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\re_name.php on line 5 filename : ( and the loop keeps on rolling down) my code is $dir = "C:\xampp\htdocs\j"; $file_open = opendir($dir); while(($file = readdir($file_open)) !== FALSE) { echo "filename : ".$file."<br />"; } closedir($file_open); i do not understand wer am i creating the mistake!! Quote Link to comment https://forums.phpfreaks.com/topic/222154-a-small-parse-error-help/ Share on other sites More sharing options...
Pikachu2000 Posted December 19, 2010 Share Posted December 19, 2010 Admittedly I'm not certain, but you may need to escape your backslashes with backslashes. I.E. c:\\directory\\dir\\file Quote Link to comment https://forums.phpfreaks.com/topic/222154-a-small-parse-error-help/#findComment-1149335 Share on other sites More sharing options...
QuickOldCar Posted December 19, 2010 Share Posted December 19, 2010 I can open a directory same as what daxguy has written in the code, I think it may be something else like permissions or something. Quote Link to comment https://forums.phpfreaks.com/topic/222154-a-small-parse-error-help/#findComment-1149341 Share on other sites More sharing options...
daxguy Posted December 19, 2010 Author Share Posted December 19, 2010 Thanks alot Pikachu2000 u are a life saver.. it was the backslashes that wer creating problems..!! Quote Link to comment https://forums.phpfreaks.com/topic/222154-a-small-parse-error-help/#findComment-1149342 Share on other sites More sharing options...
QuickOldCar Posted December 19, 2010 Share Posted December 19, 2010 I'm now wondering why I "could" do it escaped or not, lol. Maybe has to do with w/e versions using, permissions or xampp. It's cool you got it going. Quote Link to comment https://forums.phpfreaks.com/topic/222154-a-small-parse-error-help/#findComment-1149343 Share on other sites More sharing options...
Pikachu2000 Posted December 19, 2010 Share Posted December 19, 2010 Possibly a single versus double quotes thing, I suppose. Quote Link to comment https://forums.phpfreaks.com/topic/222154-a-small-parse-error-help/#findComment-1149345 Share on other sites More sharing options...
daxguy Posted December 19, 2010 Author Share Posted December 19, 2010 well another stupid issue.. well i have written the code to rename sum .mp3 files from the folder.. the folder is accessed i can read the files.. now i wanted to rename them.. like the songs are were are you - aliance.mp3 i am trying to explode the file name with symbol '-' as i just want the title of the song not the artist.. $dir = "C:\\xampp\\htdocs\\music"; $file_open = opendir($dir); $count = 1; while(($file = readdir($file_open)) !== FALSE) { $title = $file; $symbol = '-'; $pos = strpos($title, $symbol); if($pos == true) { $refined_title = explode($file, '-'); $success = rename($dir."\\".$file, $dir."\\".$refined_title[0] .".mp3"); if($success) { echo "Your files have been renamed!!"; } else { echo "Could Not Rename the files!!"; } } } closedir($file_open); The result i get is the songs get renamed but just with .mp3 nd get over written cuz all the songs get the same name.. the problem is that i cannot get the name of the file after exploding it.. the refined_title[0] is empty.. the explode aint working on this.. any oder solutions guys? Quote Link to comment https://forums.phpfreaks.com/topic/222154-a-small-parse-error-help/#findComment-1149348 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.