IrOnMaSk Posted July 25, 2011 Share Posted July 25, 2011 hi guys, so i'm doing the open/read/write... it works fine... but i got an error Warning: fopen(content.html) [function.fopen]: failed to open stream: Permission denied in D:\db\home.php on line 250 line 250: $fp = fopen("content.html", "w"); don't know why the error because it open/read/write to file just fine. how do i just comment out the error... because the error gives me all sort of problem... thanks Quote Link to comment https://forums.phpfreaks.com/topic/242765-readwrite-permission/ Share on other sites More sharing options...
doddsey_65 Posted July 25, 2011 Share Posted July 25, 2011 if you want to supress the notice then place the @ symbol infront of fopen(). although the notice is there for a reason. Quote Link to comment https://forums.phpfreaks.com/topic/242765-readwrite-permission/#findComment-1246885 Share on other sites More sharing options...
IrOnMaSk Posted July 25, 2011 Author Share Posted July 25, 2011 thanx dod, that works... although that do away with the error but just like u said the error is still there. any idea or direction on how to solve error issue? Quote Link to comment https://forums.phpfreaks.com/topic/242765-readwrite-permission/#findComment-1246892 Share on other sites More sharing options...
PFMaBiSmAd Posted July 25, 2011 Share Posted July 25, 2011 You likely already have the file open and it is locked by the operating system and then you attempt to open it again or if this is a file that gets requested by a browser, the web server is reading it and it is locked for writing when your script attempts to open it. Is that fopen() inside of a loop? Quote Link to comment https://forums.phpfreaks.com/topic/242765-readwrite-permission/#findComment-1246893 Share on other sites More sharing options...
IrOnMaSk Posted July 25, 2011 Author Share Posted July 25, 2011 hi PFM, No it's not in any loop. here's the code $date = date("m/d/y"); $time = date("h:i:s"); $page = ob_get_contents(); ob_end_flush(); $fp = @fopen("content.html", "w"); fwrite($fp, "<strong>" ."<span style = 'color:purple'>" ."Retrieving Date: " .$date ." Time: ".$time ."</strong>" ."<br />" .$page ."</span>"."<br />"); fclose($fp); and i just have this at the top starting where i wanted to start writing to file ob_start(); Quote Link to comment https://forums.phpfreaks.com/topic/242765-readwrite-permission/#findComment-1246902 Share on other sites More sharing options...
IrOnMaSk Posted July 25, 2011 Author Share Posted July 25, 2011 Err, actually it's working fine now... I've done nothing to it!!! I guess it's windows, just like it sit for a while or restart the computer!!! thanks Quote Link to comment https://forums.phpfreaks.com/topic/242765-readwrite-permission/#findComment-1246906 Share on other sites More sharing options...
PFMaBiSmAd Posted July 25, 2011 Share Posted July 25, 2011 Any chance that you also had that file open in an editor or in an editor session that died with an error of some kind? Quote Link to comment https://forums.phpfreaks.com/topic/242765-readwrite-permission/#findComment-1246910 Share on other sites More sharing options...
IrOnMaSk Posted July 25, 2011 Author Share Posted July 25, 2011 hmm i think that's probly it, because the file has the .html.., and i usually open to see if it write to it successfull, it always shows that it did write to it. so i'm not sure if i ever close it before i test the read/write... but if opening the file, while testing the write to it causes the problem, then i'm sure it must be it... thanks i'll keep that in mind Quote Link to comment https://forums.phpfreaks.com/topic/242765-readwrite-permission/#findComment-1246920 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.