View Single Post
Old 11-19-2005, 03:20 PM   #1 (permalink)
Murdoc
 
True Techie

Join Date: Apr 2005

Posts: 110

Murdoc

Default Writing and Reading a file (PHP)

Hello, I'm working a script that will write user's input into the file and echo it back after.

Here's my script:
<?php
$entry = $_REQUEST ['txt'];
$fp = fopen ("blog.dat","w+") or die ("cannot find blog database");
$write = trim(fwrite($fp,"$entry"));
while (!feof($fp))
{
$fr = trim(fgets ($fp,5000));
if (feof($fp))
{
echo "$fr";
die;
}
}

?>

When I test the code, it will show a blank page... But when I look into blog.dat this is what apepars:

test test
test test
test test

So definately, there is stuff written to the page, just that it won't read and echo it back out for some reason. If I take away the while loop, everything works fine. Can anyone help?
Murdoc is offline