php.net |  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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: maxmo at qatar dot net dot q
New email:
PHP Version: OS:

 

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-07 12:11 UTC] tony2001@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC