I am trying to retrieve client ip, page url and today's date and store it in my database. I have a table called pageviews with four parameters - "client-ip", "current-url", "current-date" and "viewcount". If there is no pageviews for today, it will create a row and store pageview for that particular day and if there is a count of pageviews, it will just update the pageviews only if the client ip is not the same as before.
But the problem is, this script is not working. Can anybody please tell me why? If possible, can you construct something better on this parameters. Any advice or solution will be highly appreciated.
Thank you.
$current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$date = date('Y-m-d');
$client_ip = $_SERVER['REMOTE_ADDR'];
echo "$current_url, $date, $client_ip";
$recent = mysqli_query($con,"SELECT * FROM pageviews")
or die(mysqli_connect_errno());
while($info = mysqli_fetch_array( $recent ))
{
$date = $info['current-date'];
$client_ip = $info['client_ip'];
$current_url = $info['current-url'];
$viewcount = $info['viewcount'];
if ($info=0) {
mysqli_query($con,"INSERT INTO `pageviews` VALUES ('$date','$client_ip','$current_url','$viewcount')");
}
else {
mysqli_query($con,"UPDATE `pageviews` SET `viewcount`=`viewcount`+1 WHERE current-date=$date AND current-ip not like $clinet-ip");
}
}