Jump to content

fopen() function and fwrite()


prezident

Recommended Posts

$DOCUMENT_ROOT=$_SERVER['DOCUMENT_ROOT'];

$outputstring = $date."\t".$tireqty." tires \t".$oilqty."oil\t".$sparkqty."
                spark plugs\t\$".$totalamount."\t".$address."\n";

//open file for appending
@$fp = fopen('$DOCUMENT_ROOT/../orders/orders.txt', 'ab');
if (!$fp)
{
    echo '<p><strong>Your order can not be processed at this time.
                    Please try again later</strong></p></body></html>';
    exit;   
}
//write to file 
fwrite($fp, $outputstring, strlen($outputstring));
flock($fp, LOCK_UN);
fclose($fp);

 

Can someone please explain to me why this Code is giving me the error?

i've tried to take out $DOCUMENT_ROOT and specify where exactly i want the file to be /dir/dir/file.txt

but it still gives me an error.

 

Link to comment
https://forums.phpfreaks.com/topic/222878-fopen-function-and-fwrite/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.