A little help. Custom counter... (Debugging)
Posted: Fri May 09, 2003 11:39 pm
(EDIT: I have been trying to debug this, but unsuccessfully. So here I post)
YepYep, learning more php and now mySQL
I've converted my user database, news, and menu to SQL. now for the counter. Here's my current code, and I keep getting the elseif outcome.
YepYep, learning more php and now mySQL
I've converted my user database, news, and menu to SQL. now for the counter. Here's my current code, and I keep getting the elseif outcome.
Code: Select all
<?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
}
?>