If this is the case you need to find the actual address of your database from your hosting control panel. Often this will be something like mysql.yoursite.com or perhaps mysql.yourhostsname.com or sometimes even a random string of numbers.
Just replace "localhost" with this address. For most larger scripts this will be found in a configuration file so if you see a config.phpz that's a good place to start your search.

