I have a PHP file with a code to increase the page views on each page visit. Summarized, it’s something like this:
design.php
...
public function increase_views() {
global $db;
$sql = "UPDATE ".self::$table." SET views = views + 1
WHERE id = {$this->id}";
$db->run($sql);
}
index.php
<?php
require_once(design.php);
...
$design->increase_views();
echo $design->views;
?>
...
<script src="javascript/validate.js" type="text/javascript"></script>
<script...
<script...
...
This increase_views() methods increases in 1 the view field in the database. However, each occurrence causes an additional increment. Since I have 3 tags, the views increase 4 by 4 instead of 1 by 1. But if I REMOVE the tags, it increases correctly (+1).
What could be the cause of this?
Do those JavaScript files exist? If not, they may be redirecting to a 404 PHP page that calls your
increase_views()function.