Use try catch then throw the exception as html
<html>
<head><title></title></head>
<body>
= newconnectAndSelectDb('not existing db');
echo "Yes I am the winner";
}catch (Exception $e)
{
echo $e;
}
?>
<br/>
<input type="text" name="text1" /><br/>
<input type="text" name="text2" /><br/>
<input type="text" name="text2" /><br/>
<div>Scrape whatever you want</div>
</body>
</html>