Kaworu
Active Coder
Hi!
I have a problem with my PHP code. The other PHP file I have takes info from some data (about orders in a web-shop) and writes it in a text file – this is working fine. What I wanna achieve with this code is to read it in my browser window, so people who will visit this site can have an easy access to this data.
The txt file is in the “orders – ok” folder and I am sure it is saved correctly. However, when I run this script in my browser, I see literally nothing – no data from this file, no messages of error, nothing. The place PHP script should “print” this data is perfectly empty.
Any help? ;-)
I have a problem with my PHP code. The other PHP file I have takes info from some data (about orders in a web-shop) and writes it in a text file – this is working fine. What I wanna achieve with this code is to read it in my browser window, so people who will visit this site can have an easy access to this data.
The txt file is in the “orders – ok” folder and I am sure it is saved correctly. However, when I run this script in my browser, I see literally nothing – no data from this file, no messages of error, nothing. The place PHP script should “print” this data is perfectly empty.
Any help? ;-)
PHP:
<?php
$document_root = $_SERVER['DOCUMENT_ROOT'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Car parts - see all orders</title>
</head>
<body>
<h1>Car parts - see all orders</h1>
<h2>Clients' orders</h2>
<?php
$wp = fopen("$document_root/orders - OK/orders.txt", "rb");
flock($wp, LOCK_SH); //blocking the file for reading
if ($wp == false)
{
echo '<p><b>No orders.<br>
Please, try later.</b></p>';
exit;
}
while (!feof($wp)) //read for the end of file
{
$order = fgets($wp);
echo htmlspecialchars($order).'<br>';
}
flock($wp, LOCK_UN); //no file blockage anymore
fclose($wp);
?>
</body>
</html>