Wait...so if the threads load directly the database is working. What pages are you experiencing this error on?