problems with fopen
| From: | Jason Jacobs | Date: | Mon, 03 Feb 2003 20:30:38 +0000 |
| Subject: | problems with fopen | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-134179@lists.php.net to get a copy of this message | ||
Afternoon all.
I've been trying to write to a text file for a while. I opened it thusly:
$file = fopen($filename, "w+");
to read it and then write to it after I modified what goes in it. The problem is it won't
write. It sets the pointer to the beginning and erases everything, but doesn't write the data
when I do:
fputs($file, $newdata);
I don't get a write error, but it just doesn't write the data. I tried opening it for a+,
and it appended the new data to the old data. I'd enjoy knowing why w+ doesn't work.
I did some searching through the list and found a workaround using tempnam and rename. That seems
to work ok, opening the original for "r". If I could just chmod the directory so
it's 755 after the data gets written, I'd be satisfied. But an exec doesn't seem to
be doing the job.
Can anyone explain why my original fopen doesn't work or tell me how to chmod the directory?
The biggest problem with this server is I don't have shell access to anything, so I have to do
everything in php code with a site user, so I don't know how much I'd be able to change.
I assume I should be able to chmod since the user I'm connecting with owns the directory.
Thanks for your help, as always.
-----------------------------
Jason Jacobs
Factory7, LLC
Support a Constitutional Amendment to protect the Pledge of Allegiance and National Motto. Go to
www.wepledge.com