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 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question php fwrite() help!

    hello again,

    this is what i need to elarn how to do, i have a script with 1 drop down box with 4 options (xbox, ps2, other cheats, pc cheats) and 2 textfields and a text erea, i need it to write it alll to a txt file (prefferably seperated with a line, im not shure how 2 do this can anyone give me a hand?

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here an example of writing to a file
    this code appends the new section to the top of the log file

    PHP Code:
    $logdata "blah\n";
    $logdata .= "blah\n";
    $logdata .= "blah\n";
    $logdata .= "blah\n";
    $logdata .= "----------\n";


    $file_arry file($logfile); //or error("Can not open \$logfile");
    $file join (""$file_arry);
    $logdata .= "\n".$file;

    $fp fopen("$logfile""w"); // error("Can not write \$logfile");
    flock($fp1);
    fputs($fp$logdata);                                                     
    flock($fp3);
    fclose($fp); 

  • #3
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Just a note, it might be safer to use the "a+" option on your fopen. Just to make sure you don't delete the contents of the existing file

  • #4
    New Coder
    Join Date
    Mar 2004
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone know what the script would llok like


  •  

    Posting Permissions

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