Re: Counters :: Double, Triple :: What The Hell

From: Date: Fri, 19 Jul 2002 21:04:40 +0000
Subject: Re: Counters :: Double, Triple :: What The Hell
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-108576@lists.php.net to get a copy of this message
for starters, add some debugging stuff like print "i'm here" maybe the function is being called from somewhere else by "accident".... or maybe something more magical is happening. but anyway, debugging output might help. also, for future reference, you can do this kind of thing much easier using one single SQL call: UPDATE counters SET {$counter}={$counter}+1 WHERE id='1' -- Scott Hurring Systems Programmer EAC Corporation scott (*) eac.com -- "Vins" <vins@webonline.co.za> wrote in message news:20020719204306.81788.qmail@pb1.pair.com... > Function CountIt($action, $counter) > { > $sql = "SELECT ".$counter." FROM counters WHERE id='1'"; > $res = mysql_query($sql); > $num = mysql_result($res, 0, $counter); > > if($action == "more") $num++; > if($action == "less") $num--; > > $sql = "UPDATE counters SET ".$counter."='".$num."' WHERE > id='1'"; > $res = mysql_query($sql); > } > > That is my script.... > I call it CountIt('more','hits'); > > but everytime i call it, the dam thing always adds 2 counts > > Can anyone identify an error > > please > >

« previous php.general (#108576) next »