If you're getting that far, then all your variables are indeed set correctly. Can you try something for me? I've attached a zip file to this message - open it, edit the username, password, database host ($dbhost), and database name ($dbname) in both files (testmysql1.php and testmysql2.php) and put both files on your server where the last10.php file is, then go to testmysql1.php in a web browser, e.g.
http://www.yoursite.com/path/to/testmysql1.php and tell me what happens.
Then go to testmysql2.php e.g.
http://www.yoursite.com/path/to/testmysql2.php and tell me what happens.
Sorry you're having problems. Hopefully this will solve it!