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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 - 27 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri May 10 12:01:32 2024 UTC