I agree with placing the DB file outside of your web root. If you can't do that, give the DB file a .php extension (or .php3 or whatever) so that it is processed by PHP. If the file is an .inc file it will just be served raw.
=== db.php ===
<?
$db = mysql_connect ( "database", "user", "pass" ) or die ( mysql_error () );
$select = mysql_select_db ( "my_db", $db ) or die ( mysql_error () );
?>
If this file is access directly, the user will see nothing. You could also test for the file being executed:
<?
if ( $PHP_SELF != "/db.php" ) {
we're not in /db.php so we must be included
... do the db connection like above
} else {
echo "This is an include file so go away!";
exit;
}
?>