I use include files and have a bit of code that tells the page to die if a variable is not defined.
Save connection string as 'sql_con.inc.php'
if(!(isset($var))) die();
$link_id = mysql_connect("localhost", "user", "password")
or die ("Could not connect: " . mysql_error());
mysql_select_db ("database", $link_id);
?>
On the page that includes the connection, place the include code after a point that defines the var.
$var = '';
include('sql_con.inc.php');
You can name the file whatever you like, and naming it something odd will keep people from guessing. Also putting it in a random directory decreases the chance of someone outside finding it.