Your variables holding the database host, username, password, and database, are all outside of the function, thus they are not a part of the function's scope. There are two ways you can get those variables into your function. One is to have them called as global variables. The other is to add them to the function arguments.
/ Pass by arguments /
function connect_to_db($host,$database,$username,$password) {
$db = mysql_connect($host,$username,$password);
mysql_select_db($database);
return $db;
}
/ Global Variables /
function connect_to_db() {
global $host,$username,$password,$database;
$db = mysql_connect($host,$username,$password);
mysql_select_db($database);
return $db;
}
Hope this helps.
-Josh