Warning: flock() expects parameter 1 to be resource, boolean given

I am a newbie trying to work through a book(Sams - PHP and MySQL Web Development by Welling/Thompson.) I am only on Chapter 2 and am stuck already. I am running some code from their CD and getting this error

Warning: flock() expects parameter 1 to be resource, boolean given in /Users/me/Sites/php/public_html/02/processorder.php on line 66

Line 66 is:
flock($fp, LOCK_EX);

Any idea what this means? Here is the code I am attempting to run

  <title>Bob's Auto Parts - Order Results</title>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
$date = date('H:i, jS F');

echo '<p>Order processed at ';
echo $date;
echo '</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 />';
  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."\	".$tireqty." tires \	".$oilqty." oil\	"
                  .$sparkqty." spark plugs\	\\$".$totalamount
                  ."\	". $address."\

// 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>';

fwrite($fp, $outputstring, strlen($outputstring));
flock($fp, LOCK_UN);

echo '<p>Order written.</p>';

You should do that “if (!$fp)” BEFORE you call flock. Chances are $fp is a boolean FALSE (meaning it failed to open the file) which would explain the error that is occuring on the flock call.

that solved it thanks