compile error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sam

    #1

    compile error

    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

  • no@email.com

    #2
    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.

    Comment

    Working...