Andrew,
The easiest way I've found for doing this is to write all the main content stuff in functions, save them in a separate file, then include that file in the header section. Once this is done, all the main content can be called in a series of conditional statement based on the return of the called functions. For example, if your attempt to connect to the mySQL backend fails, make the function returns false else it returns true (or some relevant value). For example:
<?php
function mysqlConnect($host,$user,$pass) {
$link = @mysql_connect($host,$user,$pass);
if (is_resource($link)) {
return $link;
}
else {
return false;
}
}
$return = mysqlConnect($host,$user,$pass);
if ($return) {
// do the rest of the script here
}
else {
print "Error!! Unable to establish a connection to mySQL\n";
}
?>
Hope this helps!!
Cheers,
Geoff A. Virgo