Re: How to escape from a function?

From: Date: Tue, 16 Jan 2001 23:57:54 +0000
Subject: Re: How to escape from a function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34927@lists.php.net to get a copy of this message
> And I have one more question, what is the meaning of 'or'? > e.g. > $db=mysql_connect("localhost","root","password") or die > ("could not > connect"); One more thing, which is important to me as a newbie (as I most certainly am), you can make a custom error message for the die error; which is important to me seeing as it happens a lot ;) if you want to see what the error is (for use with MySQL), use or die (mysql_error()); or use a message which will display nicely to users, if you're re-writing something which is already online and in use (not recommended). $error = "<html>\n<head>\n<title>We encountered an error!</title>\n</head>\n\n"; $error .= "<body bgcolor=\"hex value\" text=\"hex value\">\n"; $error .= "We encountered an error! Please go back to our <a href=\"http://www.site.com\">site</a>!\n\n"; $error .= "</body>\n"; $error .= "</html>"; Then, you would use something like: $connection = mysql_connect("localhost","username","password") or die ($error); If this is blatantly obvious to you, please ignore it, but at one time not too long ago, it was helpful to me. There's probably a lot neater way of doing things too ;) James.

« previous php.general (#34927) next »