note 13850 deleted from function.register-shutdown-function by jimw

From: Date: Tue, 18 Dec 2001 19:46:30 +0000
Subject: note 13850 deleted from function.register-shutdown-function by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23176@lists.php.net to get a copy of this message
I had a register_shutdown_function for making a log for the pages that ends. In the log file a want the i.p., but it don't work like i did. Exemple: register_shutdown_function("shutdown"); function shutdown() { $ip = getenv("REMOTE_ADDR"); $query = "insert into log values('','$ip','otherinfo')"; mysql_query($query); } But that don't work, if your script is shutdown't you don't have a env anymore. So thats why getenv won't work. You can solfe it like this: $ip = getenv("REMOTE_ADDR"); register_shutdown_function("shutdown"); function shutdown() { global $ip; $query = "insert into log values('','$ip','otherinfo')"; mysql_query($query); }

« previous php.notes (#23176) next »