I'm not exactly sure what you want to do, but would it be possible to do this instead?
PHP Code:
SELECT userid, count(*) as postcount, forumid FROM post, thread
WHERE post.threadid = thread.threadid GROUP BY userid,forumid;
Alternatively, you can try using REPLACE instead. It works like a DELETE followed by a INSERT.
PHP Code:
REPLACE pubscan (userid,spam,real) VALUES($bbuserinfo[userid], $countspam,$countreal);