Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts

    Posting info into a txt file using PHP

    Can someone tell me how, or direct me to a "manual" of some sort on how to do this... My CHMOD settings are correct so that's no problem - I just have no idea how! LOL

    Thanks in advance

    Taylor.
    www.ysuperleague.com

  • #2
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    620
    Thanks
    0
    Thanked 6 Times in 6 Posts
    PHP Code:
     <? 
    // Get the document root 
    $doc_root $HTTP_SERVER_VARS['DOCUMENT_ROOT']; 

    // Set file for opening 
    $fp fopen("$doc_root/data.txt"'w'); 

    // Check if can write to file 
    if (!$fp)  { 
           print 
    'Could not open desired file for writting'


    // Set what will be written to file 
    $outputstring "Hello World"

    // Finally, write to file 
    fwrite($fp$outputstring); 

    // Close the written file 
    fclose($fp); 

    ?>
    Here's the PHP manual on it:

    http://lv.php.net/manual/en/function.fopen.php


  •  

    Posting Permissions

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