Re: die function

From: Date: Wed, 23 Mar 2005 17:11:07 +0000
Subject: Re: die function
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-211394@lists.php.net to get a copy of this message
Hi all, just to give you another solution that I've successfully adopted: function die_script($errmsg) { $sendto = "xxxx@xxxx.it";
             $from = "noreply@xxxxx.com";
             $subject = "FAILED";
             $message = "CONNECTION FAILED\nTYPE OF ERROR:\n" . mysql_error();
             $message .="\n\n";
             $headers = "From: $from\r\n";
             mail($sendto, $subject, $message, $headers);
              print $errmsg . "</body></html>";
die; } $connessione = mysql_connect ("192.168.168.1","user","password") or die(die_script($errmsg)); mysql_select_db ("dbnamei"); Thanks for your help Regards Barbara
Barbara Picci wrote:
Hi all, I have a machine that must insert in cron in a mysql db in another remote machine. The problem is that I cannot know if the connection in the first machine (adsl) go down because no entry in the machine log is generated. I would like to redirect the die function in a e-mail that say me what happens.
I think the way you want to solve this problem is to create a customized error handler. Check out this link: http://php.net/manual/en/function.set-error-handler.php <?php function email_error_handler($level, $msg, $file, $line) { switch ($level) {
    /** E_ERROR, E_USER_ERROR, etc. */
    mail_to_admin("$level: $msg in $file on line $line");
} } function mail_to_admin($msg) { /** stuff */ } ?> -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Attachment converted: Barbara OS9:signature 276.asc (????/----) (000B65CD)
-- ------------------------ Barbara Picci Micro srl viale Marconi 222, 09131 Cagliari - tel. (+39) 070400240 http://www.microsrl.com

« previous php.general (#211394) next »