[clue-tech] I'm blind, or why is this PHP fwrite() failing?

Collins Richey crichey at gmail.com
Sun Sep 25 20:01:01 MDT 2005


On 9/25/05, Jed S. Baer <thag at frii.com> wrote:
> Example code: http://us2.php.net/function.fwrite
>
> My code:
>
>     $ptologfile = fopen('/tmp/contactlog.txt', 'a') || die ("Can't open
> logfile");
>     if (is_writable('/tmp/contactlog.txt')) echo '<b>Writeable</b><br>';
>     $junk = 'junk';
>     fwrite($ptologfile, $junk) || die ("Can't write to logfile");
>
> Output to web:
>
> Writeable
> Can't write to logfile
>
> Output to Apache error log:
>
> fwrite(): supplied argument is not a valid stream resource
>
> $ ls -l /tmp/contactlog.txt
> -rw-r--r--  1 apache apache 0 Sep 25 13:56 /tmp/contactlog.txt
>
> Gotta be missing something obvious, but I can't see it.
>
> I've also tried to put the file in /var/tmp and /var/www/html -- same
> results. Ownerships and permissions of directories indicate they should
> all be writeable by the webserver process running as user "apache".
>
> Thanks for any help.

FWIW, I get the same results on PHP5. Google is absolutely worthless
for this problem. One actual hit (no answer) and 30+ pages of websites
with a screenfull of this error.

Is this maybe an Apache setup error?

--
Collins Richey
      Debugging is twice as hard as writing the code ... If you write
      the code as cleverly as possible, you are, by definition, not
      smart enough to debug it.
             -Brian Kernighan
_______________________________________________
CLUE-tech mailing list
CLUE-tech at cluedenver.org
http://cluedenver.org/mailman/listinfo/clue-tech



More information about the clue-tech mailing list