Hi, Sorry I didn't mention before, but the following tracking code is "most" of my code. There's a couple other simple bits of data, which I must keep secret here, which will also be uploaded into my 8 column mySQL table. I'm mentioning this to avoid someone pointing out that I'm "reinventing the wheel," because my "webserver already logs this stuff..."
Anyway, I just want to know if a PHP expert would please look at the following code and tell me if there is anything that shouldn't/should be there, or if there is anything that is not "efficient" or, "optimized?" Thank you in advance.
<?php
$link = mysql_connect('localhost','username','password');
mysql_select_db('database',$link);
$h["ipaddress"] = getenv(REMOTE_ADDR);
$h["iphost"] = gethostbyaddr( $REMOTE_ADDR );
$h["time"] = date("Mj g:ia",time() - 10800);
$h["browser"] = getenv(HTTP_USER_AGENT);
$h["referer"] = getenv(HTTP_REFERER);
foreach(array_keys($h) as $key) {
$k .= ", ".addslashes($key);
if($h[$key] == '') { $h[$key] = "Unknown"; }
$v .= "','".addslashes($h[$key]);
}
$statement = "insert into mytrackinglog ( ".substr($k,2)." ) values ( '".substr($v,3)."' )";
mysql_query($statement,$link);
mysql_close();
?>
then my html goes here