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

David L. Anselmi anselmi at anselmi.us
Sun Sep 25 20:17:42 MDT 2005


Jed S. Baer 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

I'd have guessed that perhaps fwrite returned something useful that 
wasn't true.

> Output to Apache error log:
> 
> fwrite(): supplied argument is not a valid stream resource

But this makes it look like the fwrite really is failing.

Is it possible some security setting is interferring?  The is_writable() 
call only looks at permissions so security (e.g., that prevents PHP from 
writing to a file it doesn't own) might be the culprit.

Looking through the PHP docs reaffirms my decision to avoid learning it 
at all costs.

Dave
_______________________________________________
CLUE-tech mailing list
CLUE-tech at cluedenver.org
http://cluedenver.org/mailman/listinfo/clue-tech



More information about the clue-tech mailing list