Jump to content

Recommended Posts

hi, well, topic subject says all i guess, fopen function gives error, this is the code i use:

 

$file = "../nieuwsbrief/archief/newsletter_" . $jaargang . "_" . $editie . ".html";
$fp = fopen ($file, "w+");
fwrite($fp, constructBody($jaargang,$editie,$db_lerareninfo));
fclose($fp);

 

and this is the error i get:

 

<b>Warning</b>:  fopen(../nieuwsbrief/archief/newsletter_1_15.html): failed to open stream: No such file or directory in <b>/.../includes/filename.php</b> on line <b>111</b><br />

<b>Warning</b>:  fwrite(): supplied argument is not a valid stream resource in <b>/.../filename.php</b> on line <b>112</b><br />

<b>Warning</b>:  fclose(): supplied argument is not a valid stream resource in <b>/.../filename.php</b> on line <b>113</b><br />

 

i m 100% sure that the $editie & $jaargang variables are correct and also the contstructBody function wich returns the content of the file is PERFECT, i use these variables also for sending a mail in the same script, the fopen fwrit & fclose should store the body of the mail i have send (wich is html content) to my archive from where i use the made html files for filelisting on another place of the site, so storing in a sent box (with imap_append) is NOT an option

 

is there possibly something wrong with the w+ argument in fopen? i tought w+ means give writing rights, set pointer to the beginning of the file, and if the file does not exist, make it,...

 

any suggestions that might solve my problem?

Link to comment
https://forums.phpfreaks.com/topic/42410-solved-fopen-function-gives-error/
Share on other sites

oké nederlands toch.. ik kan en betje

 

ik weet je problem, eerst het file bestaat niet

$file = "../nieuwsbrief/archief/newsletter_" . $jaargang . "_" . $editie . ".html";
if (file_exists($file)) {
$fp = fopen ($file, "w+");
fwrite($fp, constructBody($jaargang,$editie,$db_lerareninfo));
fclose($fp);
}else{
copy($HTTP_POST_FILES['jaargang']['editie'], ../nieuwsbrief/archief/newsletter_ .$HTTP_POST_FILES['jaargang']['editie']);
fwrite($fp, constructBody($jaargang,$editie,$db_lerareninfo));
fclose($fp); }
?>

 

ik denk dit werkt, als niet zeg zo

 

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.