Jump to content


Photo

Undefined offset and fsockopen() errors


  • Please log in to reply
1 reply to this topic

#1 grenouille

grenouille
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 12 October 2006 - 07:11 PM

hi,

i found a php-function on the internet to validate an email address, but i'm getting some errors.
see the code and the errors below.
anyone any idea with might be going wrong? the function seems to work, but it produces errors in some way.

thnx in advance,

grenouille

Notice: Undefined offset: 1 in ... on line 12

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in ... on line 20

Warning: fsockopen(): unable to connect to :25 ... on line 20


function checkEmail($email) 
{
   if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) 
   {
      return FALSE;
   }
   
   list($Username, $Domain) = split("@",$email);

   if(getmxrr($Domain, $MXHost)) 
   {
      return TRUE;
   }
   else 
   {
      if(fsockopen($Domain, 25, $errno, $errstr, 30)) 
      {
         return TRUE; 
      }
      else 
      {
         return FALSE; 
      }
   }
}


#2 grenouille

grenouille
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 12 October 2006 - 07:56 PM

i found a solution myself. i thought i should post it. it is not actually a solution.
i just put an @ before the list and fsockopen functions so the errors are no longer shown.

function checkEmail($email) 
{
   if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) 
   {
      return FALSE;
   }
   
   @list($Username, $Domain) = split("@",$email);

   if(getmxrr($Domain, $MXHost)) 
   {
      return TRUE;
   }
   else 
   {
      if(@fsockopen($Domain, 25, $errno, $errstr, 30)) 
      {
         return TRUE; 
      }
      else 
      {
         return FALSE; 
      }
   }
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users