Have you made sure you've connected to your database?
I kind of can't look at your code, because I'm on my phone.
If you posted it here, I could help more.
Edit: oh, missed the error.
You got the connection to your db by the looks of it.
Make sure your username is in the form of
Code:
cpaneluser_databaseuser
So if your cpanel log in was PMS, and your DB username was smp, then your log in would be...
this doesn't go for your password.
Make sure you have written your db name i n the form of
Code:
cpanelusername_dbname
For example, you cpanel log in is PMS, and your DB name is db, it'll appear
Another thing, make sure you've added the username to the database with full permissions.