Re: Suppressing error from displaying
| From: | Richard Quadling | Date: | Thu, 25 Nov 2010 10:45:50 +0000 |
| Subject: | Re: Suppressing error from displaying | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309666@lists.php.net to get a copy of this message | ||
On 24 November 2010 19:13, Ron Piggott <ron.piggott@actsministries.org> wrote:
>
> I am using this syntax to check for a valid e-mail address
>
> list($userName, $mailDomain) = split("@", $buyer_email);
> if (checkdnsrr($mailDomain, "MX")) {
>
> if no domain is provided ( ie e-mail address is something like “ron” with no @ ) the
> following error is displayed:
>
> Warning: checkdnsrr() [function.checkdnsrr]: Host and type cannot be empty
>
> Can I suppress this from displaying so *just* my error message displays?
>
> Ron
>
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info
I would first check to see if there is an @ in $buyer_email.
if (False !== strpos($buyer_email, '@')) {
// Your code goes here.
}
If you turn on notices, you'll see you are getting ...
Notice: Undefined offset: 1 in ...
So, you are actually generating 2 errors by not checking for the @ first.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY