<?php
function counter($page = 'misc')
{
global $_users; //Make user info global
$currenthits = 0; //Preset current hits
if(!$_users['__']) //Check to see if user info is already there
getUserInfos(); //Get user info
else {} //Else do nothing
$queryA = "SELECT count FROM `site_counter` WHERE page='" .$page ."'";
$queryC = "INSERT INTO `site_counter` (`count`, `page`) VALUES ('1', '".$page."');"; //Define querys
$currenthits = mysql_query($queryA) or mysql_query($queryC) or die('Query A/C Error:'.mysql_error()); //Get count OR make new entry OR die. I'm not sure on the syntax with inline logic and parenthesies. Someone have a good tutorial?
if(!$new and (is_int($currenthits) and isset($currenthits))) {//Check IsInt&Isset
$currenthits++;// Incriment
$queryB = "UPDATE `site_counter` SET count='" .$currenthits ."' WHERE page='" .$page ."'";//Define query
mysql_query($queryB) or die('Update: '.mysql_error()); //Run or die
}
elseif (isset($currenthits) and !is_int($currenthits)) //Check for set¬ int
$currenthits = '2::1'; //(2:: for debug purposes)
else {
$currenthits = '3::1'; //else
}
return $currenthits; //return
}
?>
you dont need that else{}, you can jsut have
if(x == 1016)
then do this
the line right under will be the only line that gets executed if the 'if' statement is true
Where does the $new variable come from? You also don't seem to have used mysql_fetch_assoc() or anything else in order to get the result of the select query into a useable form (i.e. so it's not a Resouce ID).
Could you explain a bit about what the code is supposed to be doing?