Click to See Complete Forum and Search --> : Failed to open file for w+ access, permission denied problem.


Nap
03-05-2006, 04:44 PM
The php function I've written below:

function success($loginName)
{
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$filename = "$DOCUMENT_ROOT/memberlist/user.log";
$log=fopen($filename, "w+"); <===== Line 37
fputs($log, $loginName);
fclose($log);
Header("Location: secure.php");
}produces the following error:

Warning: fopen(/home/test/public_html/memberlist/user.log): failed to open stream: Permission denied in /home/test/public_html/passwordProcess.php on line 37

Can anyone explain what might be causing this error wrong? I was getting the same error before I placed the file into the memberlist folder.

Is it due to user rights? If so, what should they be set to?
Is the php.ini file set incorrectly?

Cheers,
Nap

SpectreReturns
03-05-2006, 05:38 PM
Make sure the chmod is allows writing for owner or group, so 0220 at least is required for writing.

Nap
03-05-2006, 05:56 PM
Thnx for your advice.

I did what you suggested but am still getting the same error.

I am using the master userid for the site to develop the php code.
I have set the chmod for the php file (passwordProcess.php) that is perfomring the write function to 0664, and I've also set the chmod for the target file (user.log) to 0660. Both Owner and Group have read/write access.
However, I still get the same error.

SpectreReturns
03-05-2006, 06:51 PM
Make sure the folder it's in has enough priviledges as well.

Nap
03-05-2006, 07:06 PM
I have fixed it by giving the USER.LOG file a permission setting of 777 (thus including WORLD access to read and write).

I didn't need to set WORLD permissions for the folder though. Thus the folder permissions are 770.


Does that mean there is a risk of my site being hacked?

Cheers,
Nap