Craft can't connect to db Hope you guys can help. I was working on my Craft site locally and now trying to upload it to the server but no matter what it says "Craft can’t connect to the database with the credentials in craft/config/db.php"

I have created the database in phpmyadmin along with the username and password. 

Also my hosting provider is HostGator

This is what I have locally for the db.php.

return array(

    // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
    'server' =&gt; 'localhost',

    // The name of the database to select.
    'database' =&gt; 'simple-portfolio',

    // The database username to connect with.
     'user' =&gt; 'portfolio-rc',

    // The database password to connect with.
    'password' =&gt; 'r*****',

    // The prefix to use when naming tables. This can be no more than 5 characters.
    'tablePrefix' =&gt; 'craft',

);


And the server's db.php. 

return array(

    // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
    'server' =&gt; 'localhost',

    // The name of the database to select.
    'database' =&gt; 'rchohan9_website',

    // The database username to connect with.
    'user' =&gt; 'rchohan9_portfol',

    // The database password to connect with.
    'password' =&gt; 'p************',

    // The prefix to use when naming tables. This can be no more than 5 characters.
    'tablePrefix' =&gt; 'craft',

);


Also the whole site is put in a folder so its not sitting in the root directory

Locally general.php looks like this 

return array(
    'devMode' =&gt; true,
    'siteUrl' =&gt; array(
        'en' =&gt; 'http://localhost/portfolio',
    ),
    'environmentVariables' =&gt; array(
        'baseUrl'  =&gt; 'http://localhost/portfolio/',
    )
);


and on the server it's:

return array(
    'devMode' =&gt; true,
    'siteUrl' =&gt; array(
        'en' =&gt; 'http://rachnachohan.ca/website',
    ),
    'environmentVariables' =&gt; array(
        'baseUrl'  =&gt; 'http://rachnachohan.ca/website/',
    )
);


I am completely out of ideas of why its not able to connect to the db.
I know it's been a minute since you asked this question, but just in case - I encountered this same issue - the correct credentials but still not able to connect with the db.php config file. I changed "localhost" to "127.0.0.1" and that seemed to work, or at least get me to the next snag that I hit. Cheers!