Page 1 of 1

error with writing to this file from the top without...

Posted: Mon Apr 28, 2003 8:10 pm
by synix
i'm having an error with writing to this file from the top without deleting text already on the file... i have used all of the fopen functions r,r+,w, etc. none of them work. they all either delete the current text or write from the bottom of the file. it might have something to do with usign fputs().. i duno im lost. =\. here is my php code

Code: Select all

<?
$xname = "$name";
$xmsg = "$msg";
$xemail = "$email";
$xurl = "$url";
$glog = "guestlog.php";
$fp = fopen ($glog, "r+");
$split = " - ";
if (!$xname || !$xmsg) {
echo("one or more required fields were left blank.");
}
if ($xname || $xmsg) {
fputs ($fp,"<a href="mailto:$xemail">$xname</a>$split<a href="$xurl">www</a>$split$xmsg<br><br>");
echo("thank you for your comment, i really appreciate your feedback. <a href="guestlog.php" target="shoutbox">click here</a> to view your comment.");
exit;
}
?>

Posted: Mon Apr 28, 2003 9:16 pm
by phpfreak
hi there

U are supposed to use "ab" if you want to append.check the following url

http://www.devnetwork.net/forums/viewto ... highlight=


regards
srinivas

Posted: Tue Apr 29, 2003 2:42 pm
by twigletmac
On a side note, where you've got things like:

Code: Select all

$xname = "$name";
you should get rid of the double quotes as they are totally uneccessary, so that you have things like:

Code: Select all

$xname = $name;
Mac