Hmm, I'm using the code you first posts with no edits other than login, password and db name. Plus the lines of code at the top of the page to verify cookie and set path to main.inc.php. You just posted different code. Let me try this new code on my site to see if it works.
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.