Re: PHP 4.0 Bug #8156 Updated: fopen() fails

From: Date: Fri, 08 Dec 2000 16:28:16 +0000
Subject: Re: PHP 4.0 Bug #8156 Updated: fopen() fails
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-40536@lists.php.net to get a copy of this message
Hi Jason, SORRY! what an idiot. I should have seen that my method of testing for an error is not useful in this situation. By using the || with the error message I have created the handle then immediately overwritten in with a "true" value. I will be a lot more careful with this construction in future!! Changed it to use: if ($out=fopen..) { ... } else die(..); and it works fine. Could not see how to update the report myself (it seems I would need a username) or I would have saved you the trouble. PS. One could say the manual page is a little too concise. I have added a note to warn people about this. Saw lots of these errors on other people's published pages so I am not the only idiot out there. P At 00:38 08/12/2000 +0000, you wrote:
ID: 8156 Updated by: jason Reported By: paul_tanner@alum.mit.edu Status: Feedback Bug Type: Filesystem function related Assigned To: Comments: Can you include your configure line, also can you print the output of $out after the fopen? -Jason Previous Comments: --------------------------------------------------------------------------- [2000-12-07 09:24:38] paul_tanner@alum.mit.edu You may be able to shed some light on this PHP problem. Have not used the facility to write files before so apologies if this is a simple config issue. Anything that tries to write to a file fails. I checked that the target directory is writable by the Apache user (nobody). This is set to 777. Here's a test prog: file write test <? $out=fopen("/home/handyman/DB/tmp.tmp","w") || die ("Can't open file for write"); fputs($out,"test stringn"); fclose($out); ?> Here's the result. file write test Warning: Supplied argument is not a valid File-Handle resource in /home/handyman/public_html/traveller/test.php on line 7 Warning: Supplied argument is not a valid File-Handle resource in /home/handyman/public_html/traveller/test.php on line 8 Note: It did not fail the fopen() it did, however, fail the write and the close. It creates a file of zero length. The file handle did not get created properly. But why? --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8156
------------------------------------------------------------------------- Paul Tanner +44 1494 581979 paul_tanner@alum.mit.edu mobile: +44 7973 223239

« previous php.dev (#40536) next »