cannot open file...
Posted: Wed Jun 28, 2006 5:03 pm
I have to send a string of text ($outputstring) to my file orders.txt. Of course, I can't open the file. I am supposed to send values that I have recieved from an order form($outputstring) into the text file(orders.txt).
Here is the part of the code:
Is there a logic flaw? Is the path to the file incorrect? It should referr to this path (http://mabufo.phpnet.us/learnphp/orders.txt) - correct? Or am I trying to declare the path to the nonexistant file incorrectly? (my use of 'a' in the fopen() function should create the file IIRC)
Any help is apprechiated - I'm stumped.
Here is the part of the code:
Code: Select all
//attempts to open, and then write to a file.
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
@ $fp = fopen("$DOCUMENT_ROOT/learnphp/orders.txt", 'a');
if (!$fp)
{
echo '<p><strong> Your order could not be processed at
this time. '
.'Please try again later.</strong></p>';
exit;
}
$outputstring = $date."\t".$tireqty." tires \t".$oilqty." oil\t"
.$sparkqty." spark plugs\t\$".$totalamount
."\t". $address."\n";
fwrite($fp, $outputstring, strlen($outputstring));
fclose($fp);
/* there is more code than this - but this is specifically the problem area. */Any help is apprechiated - I'm stumped.