Even though many ready made scripts come with "localhost" put in for your database by default, if you don't have dedicated hosting it usually doesn't work. 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. Just replace "localhost" with this address. For most larger scripts this will be found in a configuration file so if you see a config.php that's a good place to start your search.