I do not see anything in the code. Only thing I can note is somewhere an ad was possibly a query to add the value sold maybe failed and then when it was deleted the value was deducted and worked so the only suggestion is to use phpmyadmin and set the value to 0