Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.