#35924 [Opn->Fbk]: fopen not working
ID: 35924
Updated by: tony2001@php.net
Reported By: maxmo at qatar dot net dot q
-Status: Open
+Status: Feedback
-Bug Type: Performance problem
+Bug Type: Filesystem function related
Operating System: Linux
PHP Version: 5CVS-2006-01-07 (snap)
New Comment:
Set error_reporting to E_ALL before executing the code.
Previous Comments:
------------------------------------------------------------------------
[2006-01-07 12:00:42] 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)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35924&edit=1
Thread (2 messages)