Re: compile error



sam wrote:
HI ,
whats wrong with the following code:-
<?php
$myFile = "test.txt";
$fh = fopen($myFile, 'a');

$add="This new stuff /n";
fwrite($myFile,$add);
fclose($fh);
?>

When i run this it gave me the error:-
Warning: fwrite(): supplied argument is not a valid stream resource



change fwrite line into this:
fwrite($fh,$add);

$myFile was just a file name.
you need to pass the open file likn to fwrite funciton.
.



Relevant Pages

  • compile error
    ... whats wrong with the following code:- ... Warning: fwrite(): supplied argument is not a valid stream resource ...
    (comp.lang.php)
  • Re: Writing a structure into a file
    ... because of your 3 in fwrite. ... bin.c:10: warning: useless storage class specifier in empty ... (Use -nullpass to inhibit warning) ...
    (comp.lang.c)
  • Re: How do I prevent fwrite() overwriting text
    ... when fwrite() writes to the beginning of xyz.txt ... > existing file and write to the temp file chunk by chunk. ... fclose; ...
    (comp.lang.php)
  • Re: Cant Save File After Creating It With fopen()
    ... and then using fwrite() to write content to ... You're missing error checking. ... If you're on PHP 5, ... echo "Unable to write '$result' to '$filename'\n"; ...
    (comp.lang.php)
  • Re: I need less IIS security to fwrite via PHP
    ... the implicit assumption here is that your PHP files are run using ... anonymous authentication and that the default value has not been changed. ... PHP configuration merely allows fwrite() and fopento be invoked within ...
    (microsoft.public.inetserver.iis.security)