[solved] Question about chmod

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
8kobe
Forum Newbie
Posts: 14
Joined: Sun Mar 05, 2006 11:35 am

[solved] Question about chmod

Post by 8kobe »

Okay I want to make a log file as everyone logs on, the problem is that I ahven't dealt with chmod much. I am planning on hiding access to the file using .htlogfile.txt here

Code: Select all

//Logfile
    $file = fopen(".htmytextfile.txt","a");

   if (flock($file, LOCK_EX)){ // do an exclusive lock
   
   fwrite($file, "Write something here\n");
   flock($file, LOCK_UN); // release the lock
    } else {
   echo "Can't Logon' !";
   }

    fclose($file);
   //Logfile is basically what I want to do.
The problem is that it gives me errors of
Warning: fopen(.htmytextfile.txt): failed to open stream: Permission denied in /Users/bsucs/Sites/login.php on line 29

Warning: flock(): supplied argument is not a valid stream resource in /Users/bsucs/Sites/login.php on line 31
Can't Logon' !
Warning: fclose(): supplied argument is not a valid stream resource in /Users/bsucs/Sites/login.php on line 39

Warning: Cannot modify header information - headers already sent by (output started at /Users/bsucs/Sites/login.php:29) in /Users/bsucs/Sites/login.php on line 50


I am pretty sure these are caused by chmod. How can I change hte chmod to what I want it to be through the php? I went here http://us3.php.net/chmodbut I am not sure what to do cause I do not ever use this chmod stuff.

I got some help, thanks
Post Reply