Using an IP address in config/db.php I'm trying to set up multi-environment configs.

I have specific db settings I want to change depending on environment. I am using localhost and my Digital Ocean server IP address in my db.php file.

&lt;?php

return array(

'*' =&gt; array(
    'tablePrefix' =&gt; 'craft',
),
'localhost' =&gt; array(
        'server' =&gt; 'localhost',
        'user' =&gt; 'root',
        'password' =&gt; 'root',
        'database' =&gt; 'something',
),
'xxx.xxx.xxx.xxx' =&gt; array(
            'server' =&gt; 'localhost',
            'user' =&gt; 'some_user',
            'password' =&gt; 'some_password',
            'database' =&gt; 'somethingelse',
    ),
);


I've tried switching the order, that did not work.

Do I need to use a domain name rather than a IP address here?
The short answer is yes — you need to use a domain names.

You might also want to have a look at this multi-environment configuration method defined on the craft cookbook website that creates a global php variable called CRAFT_ENVIRONMENT in your main index.php.

I generally use that in combination with Ben Parizek technique as described in this answer.