When you try to access the $host, $user, $password vars inside your function they are out of scope. You must set them as globals in order to access them, even though your "require()" statement is inside the function -
function connect_db($db){
global $host, $user, $password;
require("db_config.php");
$link = @mysql_connect($host, $user, $password);
if(! $link){
echo"Unable to connect to the database server. Please try later";
exit();
}
if(! @mysql_select_db ($db)){
echo"Unable to locate database. Please try again later";
exit();
}
}
Hoe this helps 😉