Jump to content

read/write permission


IrOnMaSk

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/242765-readwrite-permission/
Share on other sites

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?

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();

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.