vieworder.php
<?php
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
?>
<html>
<head>
<title>Bob's Auto Parts - Customer Orders</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Customer Orders</h2>
<?php
@ $fp= fopen("$DOCUMENT_ROOT/orders/orders.txt",'rb');

if(!$fp)
{
echo "<p><strong>No orders pending.Please try again later.</strong></p>";
exit;
}
while(!feof($fp))
{
$order= fgets($fp,999);
echo $order. '<br />';
}
?>
<p>Go to <a href ="vieworders2.php">ViewOrders2</a></p>
</body>
</html>
能够成功运行,如下:
Bob's Auto Parts
Customer Orders
22:32,16th May 2011 2 tires 4 oil 6 spark plugs $264.00 22 short St,Smalltown
22:33,16th May 2011 2 tires 40 oil 6 spark plugs $624.00 22 short St,Smalltown 
可是换成另一种情况的时候就不行,高手看看
vieworder2.php
<?php
$DUCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
?>
<html>
<head>
<title>Bob's Auto Parts - Customer Orders</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Customer Orders</h2>
<?php
/*if(file_exists("$DOCUMENT_ROOT/orders/orders.txt"))
echo 'There are orders waiting to be processed.';
else
echo 'There are currently no orders.';
*/
$orders = file("$DOCUMENT_ROOT/orders/orders.txt");

$number_of_orders = count($orders);

if($number_of_orders == 0){
echo "<p><strong>No Orders pending.
Please try again later.</strong></p>";
}
echo "<table border =\"1\">\n";
echo "<tr><th bgcolor =\"#ccccff\">Order Date</th>
<th bgcolor =\"#ccccff\">Tires</th>
<th bgcolor =\"#ccccff\">Oil</th>
<th bgcolor =\"#ccccff\">Spark Plugs</th>
<th bgcolor =\"#ccccff\">Total</th>
<th bgcolor =\"#ccccff\">Address</th>
</tr>";
for($i=0; $i<number_of_orders;$i++)
{
$line = explore("\t",$orders[$i]);
$line[1] = intval($line[1]);
$line[2] = intval($line[2]);
$line[3] = intval($line[3]);

echo "<tr>
<td>".$line[0]."</td>
<td align=\"right\">".$line[1]."</td>
<td align=\"right\">".$line[2]."</td>
<td align=\"right\">".$line[3]."</td>
<td align=\"right\">".$line[4]."</td>
<td>".$line[5]."</td>
</tr>";
}
echo "</table>";
?>
</body>
</html>
就有以下的错误:
Bob's Auto Parts
Customer OrdersWarning: file(/orders/orders.txt) [function.file]: failed to open stream: No such file or directory in F:\AppServ\www\test\vieworders2.php on line 17