Need help troubleshooting DB connection I'm moving a craft install from a development to production server and am getting this error:

ERROR ERROR
Craft can’t connect to the database with the credentials in craft/config/db.php.


I've triple checked the db credentials and permissions and everything is correct. Here's my db.php file:

&lt;?php

// uncommenting this gives me a 'connected okay' so I know that the credentials are correct.
// if ($con=mysqli_connect("localhost","thandtho_db","*********","thandtho_production")) // {
//  die('connected okay');
// } else {
//  die('couldn\'t connect');
// } 

/**
 * Database Configuration
 *
 * All of your system's database configuration settings go in here.
 * You can see a list of the default settings in craft/app/etc/config/defaults/db.php
 */

// Import your local config settings
require( 'config.local.php' );

return array(
    '*'=&gt; array(
        // Database Info
        'tablePrefix' =&gt; 'craft',
    // Production Domain
    '9thandthomas.com' =&gt; array(
        'server' =&gt; 'localhost',
        'user' =&gt; 'thandtho_db',
        'password' =&gt; '***********',
        'database' =&gt; 'thandtho_production'
    ),
    ),
    // Dev
    '9thandthomas.transomco.com' =&gt; array(
        'server' =&gt; 'localhost',
        'user' =&gt; 'ninththomas_dev',
        'password' =&gt; '4iJoi58@',
        'database' =&gt; 'ninththomas_dev'
    ),
    // Local
    // Needs to be placed after production since subdomain
    // is similar to production domain name.
    $localConfig['envUrl'] =&gt;  array (
        'server' =&gt; $localDatabase['server'],
        'user' =&gt; $localDatabase['user'],
        'password' =&gt; $localDatabase['password'],
        'database' =&gt; $localDatabase['database'],
    )
);


************************** ANSWER **************************

I moved the database details from beneath the * and it worked.

db.php now looks like this:

&lt;?php
/**
 * Database Configuration
 *
 * All of your system's database configuration settings go in here.
 * You can see a list of the default settings in craft/app/etc/config/defaults/db.php
 */

// Import your local config settings
require( 'config.local.php' );

return array(
    '*'=&gt; array(
        // Database Info
        'tablePrefix' =&gt; 'craft',
    ),
    // Production Domain
    '9thandthomas.com' =&gt; array(
        'server' =&gt; 'localhost',
        'user' =&gt; 'thandtho_db',
        'password' =&gt; 'wR39fy2!k',
        'database' =&gt; 'thandtho_production'
    ),
    // Dev
    '9thandthomas.transomco.com' =&gt; array(
        'server' =&gt; 'localhost',
        'user' =&gt; 'ninththomas_dev',
        'password' =&gt; '4iJoi58@',
        'database' =&gt; 'ninththomas_dev'
    ),
    // Local
    // Needs to be placed after production since subdomain
    // is similar to production domain name.
    $localConfig['envUrl'] =&gt;  array (
        'server' =&gt; $localDatabase['server'],
        'user' =&gt; $localDatabase['user'],
        'password' =&gt; $localDatabase['password'],
        'database' =&gt; $localDatabase['database'],
    )
);
I had a similar issue where my '*' was being chosen all of the time, meaning all my environments used the same DB details.

Possibly try splitting it up, and not have a '*' for your DB details, for any environment?