Jump to content

OmarOHashim

New Members
  • Posts

    4
  • Joined

  • Last visited

OmarOHashim's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oh okay I'll try to check the permissions thanks a lot for the help!
  2. Hmm.. It tells me 'You can read and write' Is that it? Or is it something else?
  3. Thanks for the reply. I did in fact get the rest but the code stops at Your order could not be processed at this time. Please try again later. I removed The '@' and added what you have in your signature, now I get this error: Warning: fopen(/Applications/XAMPP/xamppfiles/htdocs/booktutorials/orders.txt): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/booktutorials/proccessorder.php on line 40 Line 40: $fp = fopen("$DOCUMENT_ROOT/booktutorials/orders.txt", 'ab');
  4. I am a newbie PHP Web Developer and currently reading the book 'PHP and MYSQL Web Development' by Luke Welling and Laura Thomson. Following what was written in the book, that is what I got: <?php $tireqty = $_POST['tireqty']; $oilqty = $_POST['oilqty']; $sparkqty = $_POST['sparkqty']; $address = $_POST['address']; $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; $date = date('H:i, jS F Y'); ?> <html> <head> <title>Order Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php if($tireqty == 0 && $oilqty == 0 && $sparkqty == 0){ echo '<p>You did not order anything on the previous page!</p>'; exit; }else{ echo '<p>Order Processed at '.$date.'</p>'; $totalqty = 0; $totalqty = $tireqty + $oilqty + $sparkqty; echo 'Items ordered: '.$totalqty.'<br />'; $totalamount = 0.00; define('TIREPRICE',100); define('OILPRICE',10); define('SPARKPRICE',4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo 'Subtotal: $'.number_format($totalamount,2).'<br />'; $taxrate = 0.10; $totalamount = $totalamount * (1 + $taxrate); echo '<p>'.'Total including tax: $'.number_format($totalamount,2).'<br /></p>'; echo '<p>Adress to ship to is '.$address.'<br />'; $outputString = $date."\t".$tireqty." tires \t".$oilqty." oil \t".$sparkqty." spark plugs \t".$totalamount."\t".$address."\n"; //opening files. @ $fp = fopen("$DOCUMENT_ROOT/booktutorials/orders.txt", 'ab'); /////////////////////////////////HERE IS WHERE IT WOULD NOT WORK AS I WANT TO //////////////////////////////////////////////////// if(!$fp){ echo "<p><strong> Your order could not be processed at this time. Please try again later.</strong></p>"; exit; } flock($fp, LOCK_EX); fwrite($fp, $outputString, strlen($outputString)); flock($fp, LOCK_UN); fclose($fp); echo "<p>Order written.</p>"; echo '<hr />'. file_get_contents("$DOCUMENT_ROOT/booktutorials/orders.txt"); } ?> </body> </html> All I get is 'Your order could not be processed at this time. Please try again later'. Even though I am pretty sure that the URL of the file is correct. Please help. Thanks in advance.
×
×
  • 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.