<?php
require("/config/db_config.php");
$connection = mysql_connect($db_host, $db_user, $db_password, $db_name) or die("error connecting");
mysql_select_db($db_name, $connection);
$query= "SELECT * FROM counter";
$result = mysql_query($query, $connection) or die(mysql_error());
$views = mysql_result($result, 0, "num_views");
$views++;
$query = "UPDATE counter SET num_views = $views";
echo "This page has been viewed ".$views." times";
?>
The result in the browser when I go to counter.php is this:
This page has been viewed 1 times
But when I refresh the page... or close the browser and go to the link again
I still get 1 views. Can anyone see anything wrong
IMPORTANT NOTE: The num_views does not get updated in the database, it still remains at 0.