Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Writing to files and retrieving the value

  1. #11
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Also, you're trying to fclose() a string. Should be:
    Code:
    <html>
     <body>
     <?php
     $file="file.txt";
     $fileo = fopen($file,"a");
     fwrite($fileo,"Rocks Are Cool");
     fclose($fileo);
     $filer = file_get_contents($file);
     echo $filer;
     ?>
     </body>
     </html>
    - Mike

  2. #12
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    oops, should be more carefull what i give people...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #13
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Just saying but i tested boxertrumps script first and there is nothing wrong with it... why do i need to do mburt's script (Whats the difference ?)

  4. #14
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    i accidentally fclosed a string instead of the file handle.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  5. #15
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    please give examples on evrthing you are saying also explain please on what is a file handle (i think its fopen(rest) related)

  6. #16
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    $fileo = fopen($file,"a");
    $fileo is a file handle.
    "file.txt" is a string.

    you can only close handles, not strings.
    which i the script tried to do here
    fclose($file);
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  7. #17
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok i see thanks !

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •