So every time i try learning php something goes wrong and i get discouraged. Well i just remembered these boards and decided its time to give it another shot so here goes nothing.
I am learning from a book and doing as i am told, i have even uploaded the examples to my website to make it easyer for me to see how it works while im coding it all in. i have coded all of chapter 2 and it was giving me an error or 2 .. and i tried their version and the same errors accured.. so with out further ado i shall share with you the error and codes.
error:
Bob's Auto Parts
Order Results
Order processed at 08:32, 19th June
Your order is as follows:
234 tires
34 bottles of oil
24 spark plugs
Total of order is 23 836.00
Address to ship to is sdf
Warning: fopen(/home/error-pr/public_html/../orders/orders.txt) [function.fopen]: failed to create stream: No such file or directory in /home/error-pr/public_html/test/examples/chapter02/processorder.php on line 63
Warning: flock(): supplied argument is not a valid stream resource in /home/error-pr/public_html/test/examples/chapter02/processorder.php on line 65
Your order could not be processed at this time. Please try again later.
the bold is what the error is. i have everyhtign cmoded to 755 which is all access i have the folder created and all and i just dont under stand what im doing wrong heres a direct link.
thats all the source code.. the problem for now is with the processorders.php i have yet to see if view orders is working
heres the code anyways for the processorder.php
<?php
//create short variable names
$tireqty = $HTTP_POST_VARS['tireqty'];
$oilqty = $HTTP_POST_VARS['oilqty'];
$sparkqty = $HTTP_POST_VARS['sparkqty'];
$address = $HTTP_POST_VARS['address'];
$DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
?>
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
$totalqty = 0;
$totalqty += $tireqty;
$totalqty += $oilqty;
$totalqty += $sparkqty;
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$date = date('H:i, jS F');
echo '<p>Order processed at ';
echo $date;
echo '<br />';
echo '<p>Your order is as follows:';
echo '<br />';
if( $totalqty == 0 )
{
echo 'You did not order anything on the previous page!<br />';
}
else
{
if ( $tireqty>0 )
echo $tireqty.' tires<br />';
if ( $oilqty>0 )
echo $oilqty.' bottles of oil<br />';
if ( $sparkqty>0 )
echo $sparkqty.' spark plugs<br />';
}
$total = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE;
$total=number_format($total, 2, '.', ' ');
echo '<P>Total of order is '.$total.'</p>';
echo '<P>Address to ship to is '.$address.'<br />';
$outputstring = $date."\t".$tireqty." tires \t".$oilqty." oil\t"
.$sparkqty." spark plugs\t\$".$total
."\t". $address."\n";
// open file for appending
$fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'a');
flock($fp, LOCK_EX);
if (!$fp)
{
echo '<p><strong> Your order could not be processed at this time. '
.'Please try again later.</strong></p></body></html>';
exit;
}
fwrite($fp, $outputstring);
flock($fp, LOCK_UN);
fclose($fp);
echo '<p>Order written.</p>';
?>
</body>
</html>
in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
I am learning from a book and doing as i am told, i have even uploaded the examples to my website to make it easyer for me to see how it works while im coding it all in. i have coded all of chapter 2 and it was giving me an error or 2 .. and i tried their version and the same errors accured.. so with out further ado i shall share with you the error and codes.
error:
Bob's Auto Parts
Order Results
Order processed at 08:32, 19th June
Your order is as follows:
234 tires
34 bottles of oil
24 spark plugs
Total of order is 23 836.00
Address to ship to is sdf
Warning: fopen(/home/error-pr/public_html/../orders/orders.txt) [function.fopen]: failed to create stream: No such file or directory in /home/error-pr/public_html/test/examples/chapter02/processorder.php on line 63
Warning: flock(): supplied argument is not a valid stream resource in /home/error-pr/public_html/test/examples/chapter02/processorder.php on line 65
Your order could not be processed at this time. Please try again later.
the bold is what the error is. i have everyhtign cmoded to 755 which is all access i have the folder created and all and i just dont under stand what im doing wrong heres a direct link.
thats all the source code.. the problem for now is with the processorders.php i have yet to see if view orders is working
heres the code anyways for the processorder.php
<?php
//create short variable names
$tireqty = $HTTP_POST_VARS['tireqty'];
$oilqty = $HTTP_POST_VARS['oilqty'];
$sparkqty = $HTTP_POST_VARS['sparkqty'];
$address = $HTTP_POST_VARS['address'];
$DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
?>
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
$totalqty = 0;
$totalqty += $tireqty;
$totalqty += $oilqty;
$totalqty += $sparkqty;
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$date = date('H:i, jS F');
echo '<p>Order processed at ';
echo $date;
echo '<br />';
echo '<p>Your order is as follows:';
echo '<br />';
if( $totalqty == 0 )
{
echo 'You did not order anything on the previous page!<br />';
}
else
{
if ( $tireqty>0 )
echo $tireqty.' tires<br />';
if ( $oilqty>0 )
echo $oilqty.' bottles of oil<br />';
if ( $sparkqty>0 )
echo $sparkqty.' spark plugs<br />';
}
$total = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE;
$total=number_format($total, 2, '.', ' ');
echo '<P>Total of order is '.$total.'</p>';
echo '<P>Address to ship to is '.$address.'<br />';
$outputstring = $date."\t".$tireqty." tires \t".$oilqty." oil\t"
.$sparkqty." spark plugs\t\$".$total
."\t". $address."\n";
// open file for appending
$fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'a');
flock($fp, LOCK_EX);
if (!$fp)
{
echo '<p><strong> Your order could not be processed at this time. '
.'Please try again later.</strong></p></body></html>';
exit;
}
fwrite($fp, $outputstring);
flock($fp, LOCK_UN);
fclose($fp);
echo '<p>Order written.</p>';
?>
</body>
</html>
in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?