surion Posted March 12, 2007 Share Posted March 12, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/42410-solved-fopen-function-gives-error/ Share on other sites More sharing options...
only one Posted March 12, 2007 Share Posted March 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/42410-solved-fopen-function-gives-error/#findComment-205737 Share on other sites More sharing options...
surion Posted March 12, 2007 Author Share Posted March 12, 2007 thats right, file does not excist when this is first called, but that shouldn't be a problem, when fopen sees that the file doesn't exist it should make it according to www.php.net/fopen Quote Link to comment https://forums.phpfreaks.com/topic/42410-solved-fopen-function-gives-error/#findComment-205739 Share on other sites More sharing options...
only one Posted March 12, 2007 Share Posted March 12, 2007 i dont really use php for this sort of stuf much, thats why im a bit puzzled aswell Quote Link to comment https://forums.phpfreaks.com/topic/42410-solved-fopen-function-gives-error/#findComment-205746 Share on other sites More sharing options...
surion Posted March 12, 2007 Author Share Posted March 12, 2007 solved, code was correct, rights on folders weren't Quote Link to comment https://forums.phpfreaks.com/topic/42410-solved-fopen-function-gives-error/#findComment-205809 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.