I\'d like to use the following to redirect pages that are no longer present in the database to the custom 404 page:
ob_start();
....
if ( !$found ):
header
I think your problem is because of the output buffering you're starting, or because you can't redirect with a 404. The first code example shows the output buffer starting but exiting instead of cleaning the output buffer and stopping output buffering.
Change the first example to:
if (!$found) {
ob_end_clean();
header('Location: /404.php');
exit();
}