Problems opening a text file
Posted: Mon Sep 25, 2006 11:16 pm
feyd | Please use
etc.
Error msg in my browser says:
Warning: fwrite(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\lunch\LunchOutput.php on line 97
I get this error message for each fwrite and for the fclose. It appears it is going to the C: drive instead of the server, which I don't get. I'm sure this code worked a week ago. Another strange thing is that the line number in the error message is exactly one line off for each. I don't recall seeing that before, is that a clue?
Thanks for any advice, I'm going crazy here.
SteveD
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I've done this several times, using the same code (I think). But for some reason I'm getting a strange error when I try to open a text file.Code: Select all
$file = "lunch.txt"; // define the filename for output file
print "Set Filename: $file<br>\n"; // debug line
$fhandle = @fopen($file,'a+');
print "File handle is: $fhandle<br>\n"; // debug line
/* if the file is non-zero in length, add a newline before entering this data
to separate it from the other data already there.
If the length=0 then do not start the file off with a newline. */
if (@filesize($file)!==0) {
fwrite ($fhandle,"\n");
}// if
fwrite ($fhandle,"$week=$month=Monday=$day=$breakfast_mon=$lunch_mon\n");Error msg in my browser says:
Warning: fwrite(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\lunch\LunchOutput.php on line 97
I get this error message for each fwrite and for the fclose. It appears it is going to the C: drive instead of the server, which I don't get. I'm sure this code worked a week ago. Another strange thing is that the line number in the error message is exactly one line off for each. I don't recall seeing that before, is that a clue?
Thanks for any advice, I'm going crazy here.
SteveD
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]