Please help.
When I started learning this PHP malarkey it was to build a news update system ( posh term for blog, I know ).
Anyway this took so long and was so painful that when I finally got it to work I was so happy that I accepted it as finished despite errors.
This was OK because the public would not see it...however they now will so I must ask where the hell is the error in this script...it works and I just cannot spot the error.
The upload script:
Code: Select all
<?
if($HTTP_POST_VARS['submit'])
$fp = fopen('news.txt','a');
$line = date("m.d.y") . "|" . $HTTP_POST_VARS['name'];
$line .= "|" . $HTTP_POST_VARS['news'];
$line = str_replace("\r\n","<BR>",$line);
$line .= "\r\n";
fwrite($fp, $line);
if(!fclose($fp))
?>
<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST"NAME="newsentry">
Update added by:
<INPUT TYPE="text" SIZE="30" NAME="name">
<TEXTAREA NAME="news" COLS="50"ROWS="20"></TEXTAREA>
<INPUT TYPE="reset" NAME="reset" VALUE="Start again">
<INPUT TYPE="submit" NAME="submit" VALUE="Post">
</FORM>Code: Select all
<?PHP
$data = file('news.txt');
$data = array_reverse($data);
foreach($data as $element) {
$element = trim($element);
$pieces = explode("|", $element);
echo $pieces[2] . "<BR>" . "<b>Posted by " . $pieces[1] . " on " . $pieces[0] . "</b><BR><BR>";
}
?>Warning: fwrite(): supplied argument is not a valid stream resource in /home/.sites/137/site468/web/pstore/addnews.php on line 19
Warning: fclose(): supplied argument is not a valid stream resource in /home/.sites/137/site468/web/pstore/addnews.php on line 20
Cheers for any help you can afford me - this is casuing me a real headache now.