I use this script to wirte some data to a txt file. Please check it if you can..
<?
$filename = "live.txt";
function printq ($s)
{
$s = preg_replace("/\"/", """, $s);
echo preg_replace("/''/", "'", $s);
}
if ($REQUEST_METHOD == "POST" && isset($ac) && $ac == "Zapisz")
{
$fd = fopen ($filename, "w+");
fwrite ($fd, $real_html);
fclose ($fd);
}
else
{
$fd = fopen ($filename, "rb");
$real_html = fread ($fd, filesize ($filename));
fclose ($fd);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
</head>
<body bgcolor="#56ADDA">
<p>
<table width=504 border=0 cellpadding=2 cellspacing=2>
<form method="post">
<tr bgcolor="#EEEEEE">
<td class=b13b>SKOKI NARCIARSKIE POLSKA - na ¿ywo!<br>
<textarea rows=20 cols=120 name=real_html>
<? printq(htmlspecialchars($real_html)); ?>
</textarea>
</td>
</tr>
<tr>
<td align=center>
<input type="submit" name="ac" value="Zapisz">
</td>
</tr>
</form>
</table>
</body>