My 1st function:
function db_connect_error_mail ($txt) {
mail(admin_email,mail_subject01,$txt);} //1st three variables come from constants at config.php
and 2nd function:
function connectdb() {
$dbc = mysqli_connect (db_host, db_user, db_password, db_name); //variables come from constants at config.php
if (!$dbc)
{
$txt = mysqli_connect_errno().mysqli_connect_error();
db_connect_error_mail($txt);
unset ($txt);
die('custom error message to inform viewer');
} else
{
return $dbc;
}
}
My question:
Is it okey in index.php just to call connectdb()? If db connection couldn't be set, will I get an email also? (assume that server's mail function works all time)