Jump to content

[SOLVED] fopen function gives error


surion

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

 

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.