Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Writing and Reading a file (PHP)
Closed Thread
Old 11-19-2005, 03:20 PM   #1 (permalink)
 
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  
Old 11-28-2005, 04:50 PM   #2 (permalink)
 
Newb Techie

Join Date: Nov 2005

Posts: 12

rehash

Default

go to php.net and search fseek on function list
you should be clarified after doing this
rehash is offline  
Old 11-28-2005, 06:25 PM   #3 (permalink)
 
True Techie

Join Date: Apr 2005

Posts: 110

Murdoc

Default

Quote:
Originally posted by rehash
go to php.net and search fseek on function list
you should be clarified after doing this
Thank you very much! This was what I've been looking for
Murdoc is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On