...

View Full Version : php fwrite() help!



thunderbox
04-06-2004, 10: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?

sidney
04-06-2004, 11: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);
fclose($fp);

bcarl314
04-06-2004, 01: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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum