You need to also supply the password setup for the connection. So, where you define the username and host, you also need to supply the PW.
$db_pass = "YourConnectionPassword";
Then, change this line:
@ $db = mysql_connect($hostname,$user);
to this:
@ $db = mysql_connect($hostname,$user,$db_pass);
Also, I recommend setting the dbname, host, username, password, etc in a separate include config file stored somewhere outside of the root directory.