Hi,
I have a table with 4 different columns to record IP address of people visiting my site. If a new IP comes it is recorded and a time also written on the last column.
The problem is when an exisiting IP comes again. The time becomes "0000-00-00".
Here is the code after you already connect with the database and an IP is found on the database or not.
Note: $Username_Found is a variable == 1 when an IP address is already found on the database. Default is not found == 0.
[code=php]
if ($Username_Foun d == 1){
$counter = $counter + 1;
mysql_query("UP DATE IPLog SET TimesVisit = $counter WHERE User_IP = '$ip'");
mysql_query("UP DATE IPLog User_Time = $User_Time WHERE User_IP = '$ip'");
}
if ($Username_Foun d == 0){
$IPCount = $IPCount + 1;
$TimesVisit = 1;
$sql="INSERT INTO IPLog (IPCount,User_I P, TimesVisit, User_Time)
VALUES
('$IPCount','$i p','$TimesVisit ','$User_Time') ";
if (!mysql_query($ sql,$con))
{
die('Error: ' . mysql_error());
}
}
[/code]
Thank you.
I have a table with 4 different columns to record IP address of people visiting my site. If a new IP comes it is recorded and a time also written on the last column.
The problem is when an exisiting IP comes again. The time becomes "0000-00-00".
Here is the code after you already connect with the database and an IP is found on the database or not.
Note: $Username_Found is a variable == 1 when an IP address is already found on the database. Default is not found == 0.
[code=php]
if ($Username_Foun d == 1){
$counter = $counter + 1;
mysql_query("UP DATE IPLog SET TimesVisit = $counter WHERE User_IP = '$ip'");
mysql_query("UP DATE IPLog User_Time = $User_Time WHERE User_IP = '$ip'");
}
if ($Username_Foun d == 0){
$IPCount = $IPCount + 1;
$TimesVisit = 1;
$sql="INSERT INTO IPLog (IPCount,User_I P, TimesVisit, User_Time)
VALUES
('$IPCount','$i p','$TimesVisit ','$User_Time') ";
if (!mysql_query($ sql,$con))
{
die('Error: ' . mysql_error());
}
}
[/code]
Thank you.
Comment