You are here: [PHP] Re: die function « PHP « IT news, forums, messages
[PHP] Re: die function

Posted by Barbara Picci on 10/03/67 11:12

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация