Here is a snap shot of the code I am having trouble with.
When i write to the file it also includes a space between all the html code. As in code on line 1, blank on line 2, code on Line 3 and so. Since this is a guestbook script and i keep writing to the same file the problem just keeps getting worse until it wipes out the whole file.
The problem I think is fputs because i have tested the $file just before fputs and it seems to be fine.
Any idea anyone?
$DIR = "c:/apache/htdocs/writer/story3/";
$MOTIF = "<!-- Value_Add_Comments -->";
if ($action == write)
{
$GUEST_FILE = $DIR;// . $from;
$GUEST_FILE .= $from;
$date = date("d/m/Y");
$file_arry = file($GUEST_FILE);
$file = join ("", $file_arry);
$name = htmlspecialchars($Name);
$email = htmlspecialchars($EMail);
$title = htmlspecialchars($Title);
$comment = htmlspecialchars($Comment);
$add = $MOTIF;
$add .= "<table border='0' cellspacing='0' cellpadding='3'><tr><td><A HREF=\"mailto:$email\">$name</A></td></tr><tr><td>Date : $date</td></tr><tr><td>$comment</td></tr></table>";
$file = preg_replace("/$MOTIF/", $add, $file);
$fp = fopen("$GUEST_FILE", "w");
flock($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
}