non mettere il die() ma se la funzione rende un false fai un redirect

codice:
if ($db == FALSE) {
  header("location: ./pagina_errore.php");
}