Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with DIR Permissions

Newbie
 
Join Date: Oct 2007
Posts: 27
#1: Mar 19 '08
I wrote a script to log MySQL connections into a log file ...
So that whenever and wherever in the different part of the scripts , I need to connect , I could use this code to connect as well as track the connections to a log.

This is the code.
[PHP]
<?
$username="xxxx";
$password="xxxx";
$port="xx";
$ip = getenv("REMOTE_ADDR") ; // User IP address
$host="xxxx";
$database="xxxx";
$logfile="./conlog.txt";
$time=date("d/m/Y - H:i:s A");

$connectid=mysql_connect($host,$username,$password );
if($connectid){$log1="Connecting to server [$host]....Done";}
else{$log1="Connecting to server [$host]....Failed (".mysql_error().")";}

$connectdbid=mysql_select_db($database);
if($connectdbid){$log2="Switching to database [$database]....Done";}
else{$log1="Switching to database [$database]....Failed (".mysql_error().")";}

// Log Processes (./log.)
$usr="\nRequest from user [$ip] on [$time]";
$log=$usr."\n$log1\n$log2";

$fp=fopen($logfile,"a");
$add1=fputs($fp,$log);
$close1=fclose($fp);

//done

?>
[/PHP]
This thing is working but whenever I include it with the PHP's
Expand|Select|Wrap|Line Numbers
  1. include()
function in other parts of the script , I get this error:
Expand|Select|Wrap|Line Numbers
  1. Warning: fopen(./conlog.txt) [function.fopen]: failed to open stream: Permission denied in /home/veg1/public_html/modules/connectdb/connectsqldb.php on line 27
  2.  
  3. Warning: fputs(): supplied argument is not a valid stream resource in /home/veg1/public_html/modules/connectdb/connectsqldb.php on line 28
  4.  
  5. Warning: fclose(): supplied argument is not a valid stream resource in /home/veg1/public_html/modules/connectdb/connectsqldb.php on line 29
  6.  
Please help me asap.
Thanks so much.

Member
 
Join Date: Nov 2007
Location: Russia, Saint-Petersburg
Posts: 82
#2: Mar 19 '08

re: Help with DIR Permissions


Anyway, read following:
http://php.net/manual/en/function.fopen.php

Edited: thought it was IIS.
Reply