Hello to all,
I am using the following code to capture stats from my login page to a Mysql database table log_file.
<?PHP
// Logs the user IP
$ip = $REMOTE_ADDR;
// Logs the time accsessed
$time = date("Y m j h i s");
$u="$username";
//Logs the referer
$referer = $HTTP_REFERER; //$http_referer is PHP variable to get referer
//Logs the browser
$browser = $HTTP_USER_AGENT; //$http_user_agent is PHP variable for browser
$result=MYSQL_QUERY("INSERT INTO log_files (userbrowser,username,userip,accesstime) ".
"VALUES ('$browser','$u','$ip','$time')");
// Close the file
//fclose($fp);
?>
I can store the date as a string which is what it is doing, however, that does not do me any good when I query based on date because it is a string. I have changed the accesstime from Varchar to datetime. However, the value is just 0000000000. When I call my log file using Log.php it displays all my other fields and 00000000 for accesstime field. If I switch the field back to varchar it displays the date and time correctly. However, I want to be able to store a date and time in datetime field and retrive using my log.php file i created to display the date/time as I wish.
Any feeback is appreciated.
jchapa aka theranchhand