#35924 [NEW]: fopen not working

From: Date: Sat, 07 Jan 2006 11:00:43 +0000
Subject: #35924 [NEW]: fopen not working
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-91639@lists.php.net to get a copy of this message
From:             maxmo at qatar dot net dot q
Operating system: Linux
PHP version:      5CVS-2006-01-07 (snap)
PHP Bug Type:     Performance problem
Bug description:  fopen not working

Description:
------------
I am trying to look for a file, if exisit it should open it for reading
and writing, if not it should create one for me. The code works fine on
"PHP Version 4.3.4" but does not work with "PHP Version 5.0.4". I have set
the folder and file permission to 777 as its a counter file.

Reproduce code:
---------------
<?php
$filename = "/homepages/domain/demo1/counter/auction_id.txt";

$somecontent = "1";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

   if (!$handle = fopen($filename, 'w+')) {
         echo "Cannot open file ($filename)";
         exit;
   }

   if (fwrite($handle, $somecontent) === FALSE) {
       echo "Cannot write to file ($filename)";
       exit;
   }

   echo "Success, wrote ($somecontent) to file ($filename)";

   fclose($handle);

} else {
   echo "The file $filename is not writable";
}

?>

Expected result:
----------------
If file exists it should open and add 1, if not it should create a new
file and add 1.



Actual result:
--------------
Cannot open file (/homepages/autorepodepot/demo1/counter/auction_id.txt)

-- 
Edit bug report at http://bugs.php.net/?id=35924&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35924&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35924&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35924&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35924&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=35924&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35924&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35924&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35924&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35924&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35924&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=35924&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=35924&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35924&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35924&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35924&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35924&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35924&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35924&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35924&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35924&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#91639) next »