PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
NewbiePHP
Forum Newbie
Posts: 4 Joined: Tue Jan 10, 2006 8:39 am
Post
by NewbiePHP » Thu Jan 12, 2006 8:49 am
i am opening a file in a textarea and people can edit it and save it..
its work fine adding stuff to the file and saving it..
BUT if i delete stuff from the fiel and save it it doesnt do it!.. why?
cause the file size is smaller? less data in it??
heres the code i have written
$FilePath = $_POST['Path'];
$FileData = $_POST['filedata'];
$SortedData = stripslashes($FileData);
$FileName = $FilePath;
$FilePointer = fopen($FileName, "r+");
fwrite ($FilePointer, $SortedData);
fclose($FilePointer);
cheer all
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 12, 2006 8:52 am
"r+" is reading with appending.
use "wt" (writing in text mode)
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu Jan 12, 2006 8:53 am
shouldn't you open the file with "w" not "r+"
NewbiePHP
Forum Newbie
Posts: 4 Joined: Tue Jan 10, 2006 8:39 am
Post
by NewbiePHP » Thu Jan 12, 2006 8:57 am
cool that works... but now its adding spaces between each line of code.
i had
;
:
#
~
}
{
and then more spaces between them after i edit the file eg below
;
:
#
~
}
{
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Thu Jan 12, 2006 10:00 am
what is this posted data you are writing? you sure it does not contain any of those chars? echo it out first and see what it is.
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Thu Jan 12, 2006 10:21 am
play around with "t" (text) modifier