Re: or die

From: Date: Mon, 24 Jul 2000 04:31:39 +0000
Subject: Re: or die
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-7820@lists.php.net to get a copy of this message
"Tyler Longren" <tyler.longren@midiowa.net> wrote in message news:200007210345.WAA12108@nevada1.nevia.net... > > Hello all- > > I was wondering if the following is possible: > > <? > mysql_connect("host","user","passwd") or die > ("mysql_pconnect("host","user","passwd")"); > ?> Sort of, but that usage doesn't make sense based on the way mysql_pconnect works. If you want custom error reporting, you can generate the text for die() using a function: function my_error($message) { if ($REMOTE_ADDR == $DEVELOPER_ID) { return $message; } else { mail("developer@domain", "Hey stupid", $message); return "An error occurred. The programmer will be flogged"; } } mysql_pconnect($Host, $User, $Password) or die(my_error(mysql_error())); Alternately, if you simply wanted to run something else, nothing says you have to use die: mysql_pconnect($Host, $User[0], $Password) or mysql_pconnect($Host, $User[1], $Password); The statement after the or should be executed every time the first statement returns false: try() or try_harder(); Chris

« previous php.general (#7820) next »