Hi
its a simple problem, im sure you will laugh at me for asking,
in basic im running a program called wamp which runs php apache server and mysql, my ps is a vista 64 bit operating system
wamp requires i put all php and files into the www folder to run them through the wamp interface this all works fine
heres the dilema
when i attempt to write to a new flat file using php it gives me this error
Warning: flock() expects parameter 1 to be resource, boolean given in C:\wamp\www\bobscars\processorder.php on line 75
this is the php code in question
<?php
// create short variable names
$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>Bob's Auto Parts - Order Results </Title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order Processed at ".date('H:i, jS F Y')."</p>";
echo "<p>Your order is as follows: </p>";
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo "Items ordered: ".$totalqty."<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 />";
}
}
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
$totalamount = number_format($totalamount,2, '.',' ' );
echo "<p>Total of order is $".$totalamount."</p>";
echo "<p>Address to ship to is ".$address."</p>";
$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');
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, strlen($outputstring));
flock($fp, LOCK_UN);
fclose($fp);
echo "<p>Order Written.</p>";
?>
</body>
my suspiscions are windows will not give it permision to make a file, or that the document path is not acurate
i would look forward to any advise you have i understand best way to manage data would be through a database but im still learning,