It depends on how your provider setup access. I usually setup a username and password for users and I use the machine host name instead of localhost.
My grant statements usually look like this ...
grant select, insert, update, delete on mytable.* to username@my.host.com identified by 'password';
With this example, a mysql_connect woudl look like this ...
$connection = mysql_connect("my.host.com","username","password");