Hi John and his colleagues ... I am new to programming and MYSQL ... however, the way I circumvented it was as follows:
I use some PHP code to query the DB and then evaluate both columns, ip and page_url , and if they evaluate to true, do nothing, otherwise ... paste / execute the code shown above by Eugene Rick ...
$ip = $_SERVER['REMOTE_ADDR']; // Get IP Address. $purl = htmlspecialchars($_GET['page_url']); // Get Page URL. $results = $mysqli->query("select * from hits"); // Query hits table. $row = $results->fetch_assoc(); // Fetch array and assign to $row, then evaluate with if statement. if ($row['ip'] == $ip && $row['page_url'] == $purl) { } else { $mysqli->query("insert into hits (ip,page_url,counter) values ('$ip','$purl',1) on duplicate key update counter=counter+1"); }
To be honest, I did not check this on more than one IP address, just mine.
However, it adds rows to the hit table for each URL inserted based on a unique ip (the one I am currently using), and does not increase the number of hits for any inserted URL when the page refreshes, so I assume that she works...
source share