The only thing you are doing in that code is defining the hostname, user, password, dastabase and prefix and storing them in variables. You are not actually doing anything with them. For this, you use the mysql_connect function stored in a variable;
CODE
$dbh=mysql_connect ("$mysql_hostname", "$mysql_user", "$mysql_password") or die ('Error connecting to MySQL ' . mysql_error());
All that code does is uses the values from the variables and connects to the server, otherwise it will output a MySQL error. To choose the database, you simply use the mysql_select_db function;
CODE
mysql_select_db("$mysql_database");
If the connection is successful, it will search for the database which is defined in the variable $mysql_database. It's as simple as that

Your full code for connecting to the database will look something like this;
CODE
<?php
$mysql_hostname = " ";
$mysql_user = " ";
$mysql_password = " ";
$mysql_database = " ";
$prefix = " ";
$dbh=mysql_connect ("$mysql_hostname", "$mysql_user", "$mysql_password") or die ('Error connecting to MySQL ' . mysql_error());
mysql_select_db("$mysql_database");
?>
If you need any more help feel free to email me

(Don't add me on any IM)