logging - PHP fwrite() not writing to log file -


as 1 of first php projects i'm creating ip logging script logs user's ip address. reason fwrite() function doesn't seem writing logfile.

can me out?

<?php // ip logger script // sam lev // sam@levnet.us $iplogfile = 'iplog.txt'; $ipaddress = $_server['remote_addr']; $webpage = $_server['script_name']; $timestamp = date('m/d/y h:i:s'); $browser = $_server['http_user_agent']; $fp = fopen($iplogfile, 'a+'); chmod($iplogfile, 0777); fwrite($fp, '['.$timestamp.']: '.$ipaddress.' '.$webpage.' '.$browser. "\r\n"); fclose($fp); echo "ip address: $ipaddress <br />\n"; echo "timestamp: $timestamp <br />\n"; echo "browser: $browser <br />\n"; echo "information logged server. <br />\n"; ?> 

iplog.txt still blank after running script. echos out fine.

thanks

your code checks out , it's permissions issue.

either manually chmod file 0777

or add chmod($iplogfile, 0777); after $fp = fopen($iplogfile, 'a');

chmod standard server command not exclusive php.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -