I have got an issue with this php code?

tnj

New member
Basically I wrote a php code by following some instructions that were given by my teacher. I have an issue with the last part of the php code, I went trough the code lots of time and it still gives some errors. Here the php code and the errors.

PHP code:

<?php
$myfile = fopen('orders.txt', 'a');
flock($myfile, LOCK_EX); //Lock the file for writing
$outputstring = date('H:i jS F'). "|\t Suit: ".$suitqty." |\t Shoe: ".$shoeqty."|\t Jacket: ".$jacketqty." |\t Belt: ".$belt."|\t Waistcoat: ".$waistcoatqty." \n";
fwrite($myfile, $outputstring);
flock($myfile, LOCK_UN); // Release write lock
fclose($myfile);
if (!$myfile)
{
echo '<p><strong> Your order could not be processed at this time. Please try again later.</strong></p>';
exit;
}
echo '</p>';
?>

Errors:

Warning: fopen(orders.txt) [function.fopen]: failed to open stream: Permission denied in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 164

Warning: flock() expects parameter 1 to be resource, boolean given in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 165

Warning: fwrite(): supplied argument is not a valid stream resource in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 167

Warning: flock() expects parameter 1 to be resource, boolean given in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 168

Warning: fclose(): supplied argument is not a valid stream resource in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 169
 
Back
Top