Gregadeath Posted July 14, 2007 Share Posted July 14, 2007 I'm having a spot of trouble using the fwrite() function. - the preceding fopen() call does generate a new file as expected, and, if it already exists, overwrites the file. - permissions on the folder I'm using are set to 777 - on the fwrite() and fclose() lines, this error message is generated: Warning: fwrite(): supplied argument is not a valid stream resource in... Here's the code: $theDoc="../../xml/techList.html"; // The fopen() line works as expected, creating a new document techList.html and overwriting an existing document. $newDoc=fopen($theDoc,"w"); //The fwrite() doesn't. Error message (type appears. $write=fwrite($theDoc,"If you can read this, it works."); //the next line returns "write is " echo "write is $write"; //this line also generates a type 8 error message. $newDoc=fclose($theDoc); When I have to ask for help, it's nearly always because there's something very basic and stupid I've overlooked. I suspect that this is also the case here. So, if you can tell me what I've missed, I'd be very happy to getting around to the business of kicking myself and getting it right. Quote Link to comment Share on other sites More sharing options...
metrostars Posted July 14, 2007 Share Posted July 14, 2007 <?php $theDoc="../../xml/techList.html"; // The fopen() line works as expected, creating a new document techList.html and overwriting an existing document. $newDoc=fopen($theDoc,"w"); //The fwrite() doesn't. Error message (type appears. fwrite($theDoc,"If you can read this, it works."); //this line also generates a type 8 error message. $newDoc=fclose($theDoc); ?> Quote Link to comment Share on other sites More sharing options...
Gregadeath Posted July 14, 2007 Author Share Posted July 14, 2007 Nope, it's not that basic. I did see the problem, though, and correct it after taking a short nap. Thanks for your help, though - I'm sure I'll be back again. The other question I have, then: I'm new here, so how does one close a thread where the problem is solved? <?php ... ?> Quote Link to comment 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.