Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying data in a flat file...

Status
Not open for further replies.

Whispers

Technical User
Mar 20, 2002
2
US
I'm just getting the hang of working with php, but I've run into a break wall with modifying and editing flat files.

I have a guestbook and I would like to be able to correct the spelling of entries or delete individual entries in a flat file.

I would even like to add replies, but I would like to do this by adding text directly to $comment. Could anyone help?

What if I want to single out the names of each submitee, or just those who've submitted email addresses? I apologize if I my seem unclear in any respect, I just didn't want to drain you in code.

I appreciate any assistance,

Tony Whispers
 
Best thing to do would be thoroughly digest the fwrite() section and related bit on the PHP site and also read and understand all additional user comments.
It took me a while to get the hang of but will enable you to do everything you want to.

$fp = fputs($myfile, "There is alot here");//write There was alot here to $myfile
$fp = fseek($myfile, (6),SEEK_SET);//find position 6(wraps on newline)
$fp = fputs($myfile,sprintf("was something"),4);//write the first 4 characters of the statement (was ),text now reads There was alot here.

$pos = ftell($myfile);//find the cursor position, use with fseek to move cursor position
$fp = fseek($myfile, (5 + $pos),SEEK_SET); ***************************************
Party on, dudes!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top