View Full Version : php fwrite() help!

04-06-2004, 09:36 AM
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?

04-06-2004, 10:43 AM
here an example of writing to a file
this code appends the new section to the top of the log file

$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($fp, 1);
fputs($fp, $logdata);
flock($fp, 3);

04-06-2004, 12:45 PM
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

04-07-2004, 07:30 AM
anyone know what the script would llok like