这是我的 sql 代码,我多次运行相同的代码并且从未遇到任何问题,但今天或某些原因。
mysqli_query($con, "
INSERT INTO 'u_visits'
('ip_adress','dates')
VALUES
('$ip',now())
ON DUPLICATE KEY UPDATE visits = visits + 1
");
mysqli_close($con);
一切正常,除了我的日期行被添加为 0000-00-00 00:00:00
这是我获取IP地址的方法:
//Test if it is a shared client
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
//Is it a proxy address
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$ip = ip2long($ip);