@sFishy: The code above works and reliable even if you delete ALL records in your WHOLE database..
The logic that lies behind is that:
Your database tables give an id number to all records while saving them. This unique id number will be increased by 1 with every new record and since it's unique, even if you delete the record, same id # will never be assigned to a new record.
The original vbulletin code above counts the existing (undeleted) database records while calculating the message and threads numbers. However my code checks what the largest id number is in the table. If, say, it returns 4567, you are very likely to have less messages in your database, since some can be deleted in the past, but you can be sure that from day one to today, you created exactly 4567 threads whether some deleted or some exists.
See?
Regards,
Logician