Hi, I need help with the server location my file path for the text file order.txt.
according to my php text book, this is what they say I should use:
@ $fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'rb');
however, this didn't work the server doesn't recognize where the file is located.
This line below me is the absolute path and it works so I want to know if there is something wrong with the first method
@ $fp = fopen("c:\Program Files\Apache software Foundation\Apache2.2\htdocs\orders\orders.txt", 'rb');
This is the code:
<?php
//create short variable name
$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 />';
}
echo 'Final position of the file pointer is '.(ftell($fp));
echo '<br />';
rewind($fp);
echo 'After rewind, the position is '.(ftell($fp));
echo '<br />';
fclose($fp);
?>
</body>
</html>