Jump to content

file_put_contents sometimes working...


malda

Recommended Posts

hi,

i got a strange problem with php.

i made a kind of logbook system using a file called log.php

 

i got a file called logging.php that i include in the pages that need not be logged.

<?php
function logtofile($msg)
{
$userIp    = ( isset($_SERVER['REMOTE_ADDR']) && ($_SERVER['REMOTE_ADDR'] != "")) ? $_SERVER['REMOTE_ADDR']     : "Unknown";
$actualTime = date("d/m/Y H:i:s");
$file = "log.php";
$log = "[" . $actualTime . "] : [" . $_SESSION['user'] . "] : [" . $userIp . "] : " . $msg . "<br>";
file_put_contents($file, $log, FILE_APPEND);
}
?> 

it works fine but theire is one page that deals with mysql "DELETE...." and theire get the error

Warning: file_put_contents(log.php) [function.file-put-contents]: failed to open stream: Permission denied in /var/www/myaccount/wwwroot/test/admin/logger.php on line 11

 

my permissions are set good (as far i know) my webserver user is owner of the file log.php and it is set to chmod 644 (also tried to set it to 777 but it doesn't help)

 

i already searched alot of webpages but no-one seems to have the problem that it doesn't work at one page only.

 

if theire is anybody who has any ideas, please let me know

 

MODIFIED: the code that refuses is

 logtofile("ERROR delteing sid 'not empty' for sid ---> '" . $_POST['sid_dropdown'] . "'");

Link to comment
https://forums.phpfreaks.com/topic/167776-file_put_contents-sometimes-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.