|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35924 fopen not working
Submitted: 2006-01-07 12:00 UTC Modified: 2006-01-15 01:00 UTC
From: maxmo at qatar dot net dot q Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5CVS-2006-01-07 (snap) OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-01-07 12:00 UTC] maxmo at qatar dot net dot q
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:
$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)";

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

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


} 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)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-07 12:11 UTC]
Set error_reporting to E_ALL before executing the code.
 [2006-01-15 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 22 13:01:24 2020 UTC