Swapping dreamhost databases - unable to connect to subdomain database


I’m managing a site that’s split up between a domain and subdomain (both hosted by Dreamhost). They use two different databases (let’s call them “www” for the main domain and “blog” for the subdomain), but the same host, username and password.

When I’m in www, I can connect to the database like so:

$databaseConnection = mysql_connect($host, $username, $password, new_link) or die (‘I can’t connect to the database.’);
@mysql_select_db($database,$databaseConnection) or die(“Still Unable to select database”);

When I set $database to the www database, everything works fine. When I try to use the above code when I set $database to the blog database (using the same host, username and password), I get “Still unable to select database”.

This seems like it should be easy - is there a special setting I need to do this with Dreamhost?


any typos in your config?
any more details from the logs?
there shouldn’t be a problem hosting more than one database with the same connection details… although you might consider at least a different password for each if you are concerned about security.


No typos - that’s why I used the same host, username and password! (Will change later for security).

So I’m n00bish with MySQL - how do I check the logs?

Also - this call is being made from a Wordpress page (an include placed on single.php). Could that be the issue? That I’m using Wordpress?

Thanks in advance for your help!


if WP was installed by DH, they add a bit of salt to the beginning of the WP tables, but I can’t recall whether they do this with the DB name or not. all i can think of is verify that the DB name is the same in your settings as what it is in the actual DB.