Item counters not decreasing

Working on an auction site and the category counters are not decreasing, only increasing, giving the sense there are more auctions then there really are. I have found code that I believe adjusts this value:

[php]function addcatcount ($catid) //adds a category count to each relevant category
{
$cnt = 0;
if($catid > 0) {
$croot = $catid;
while ($croot>0) {
$crw = getSqlRow(“SELECT parent FROM auction_categories WHERE id=’$croot’”);
$addcount[$cnt++] = mysql_query(“UPDATE auction_categories SET items_counter=items_counter+1 WHERE id=’$croot’”) or die(mysql_error());
$croot = $crw[‘parent’];
}
}
}

function delcatcount ($catid) //removes a category count to each relevant category
{
$cnt = 0;
if($catid > 0) {
$croot = $catid;
while ($croot>0) {
$crw = getSqlRow(“SELECT parent FROM auction_categories WHERE id=’$croot’”);
$delcount[$cnt++] = mysql_query(“UPDATE auction_categories SET items_counter=items_counter-1 WHERE id=’$croot’”) or die(mysql_error());
$croot = $crw[‘parent’];
}
}
}[/php]

The count for the total live auctions is correct but the problem is in the category counts. Any help would be appreciated.

Thanks,

Tom

Sponsor our Newsletter | Privacy Policy | Terms of Service