fopen, fputs, fwrite, fclose, fdammit
| From: | Max Graham | Date: | Fri, 01 Nov 2002 00:48:33 +0000 |
| Subject: | fopen, fputs, fwrite, fclose, fdammit | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-16643@lists.php.net to get a copy of this message | ||
I'm trying to put a comment page on my weblog. I have the link displayed in
the format of date first, then a link to bookmark the entry, and then a link
to post a comment. I want to write the comments to a text file. My comment
page accepts a default value of "target", which is set to the date to be
commented on. Then it opens (or creates) a text file in the format of the
variable set by $pctarget.
$pctarget = "/blogbits/".substr($target,0,6)."/_".$target."_bc.txt";
if ($newpost == "yes") {
$addrecord =
$newpostname."\n".$newpostemail."\n".$newposturl."\n".date("l, F
jS,
Y")."\n".$newpostcomments."\n<br>";
$fullcomments .= "-----splitcomment-----\n";
$getcomments = fopen($pctarget, "a");
fputs($getcomments, $addrecord);
fclose($getcomments);
}
I've tried assigning fputs() and fclose() to variables (which I infer is the
right way to do things but the manual isn't clear on it, i.e.
$gc=fputs($getcomments, $addrecord); but that doesn't work either. When the
page loads I get a blank page and this for the source:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
It's not even the header source I told it to put out. As I understand it,
this is the source put out by an error page, when the code won't run. I
haven't been able to figure out what simple thing I'm missing, and I know
it's simple because it invariably is. (Law of Murphy, don't ya know.)
Any suggestions? Would lack of file permissions cause this? Server is a
Linux box.
Thanks in advance