In place of hostname you have to use IP address of the net host
$db_link = mysql_connect($hostname, $dbuser, $dbpassword)
but it is not enough. In MySQL there is a user table. In the table there is host field.
This field usually set to localhost for security sake.
You have to ask hosting provider to change host field
to your site.com IP or to '%' then user from any IP could connect to MySQL database.
Please see site www.configure-all.com and select Database design from main menu
and then select MySQL manual. It is about security in MySQL
Good luck