Find invalid email formats using MySQL query.

2006-05-20 Thread Yesmin Patwary
Dear All,
   
  My contact table has email field which contains many invalid email addresses. 
I find them using following php function.  Is there a way to do that check in 
MySQL query?
   
  function emailValidate ($str)
 {
$reg = ^([a-zA-Z0-9._-]+)@([a-zA-Z0-9-])+(\.[a-zA-Z0-9-]+)+$;
if (eregi($reg, $str)) {
 return true;//-- good email
 }else{
 return false;//--bad email
 }
  }//--close function

  Thanks in advance for any comments or help.


-
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates 
starting at 1cent;/min.

Re: Find invalid email formats using MySQL query.

2006-05-20 Thread Keith Roberts
Well, mysql has support for regex matching. The thing is 
though, why store invalid email addresses in you database?

I think what you are doing is the right approach.

Check the email address validity first in php BEFORE saving 
it to the database. At least you then know you are only 
storing valid emails in your database.

If you store invalid emails in your database then how do you 
get the user to correct the email address from mysql?

HTH

Keith

In theory, theory and practice are the same;
in practice they are not.

On Sat, 20 May 2006, Yesmin Patwary wrote:

 To: mysql@lists.mysql.com
 From: Yesmin Patwary [EMAIL PROTECTED]
 Subject: Find invalid email formats using MySQL query.
 
 Dear All,
My contact table has email field which contains many 
   invalid email addresses. I find them using following php 
   function.  Is there a way to do that check in MySQL 
   query?

   function emailValidate ($str)
  {
 $reg = ^([a-zA-Z0-9._-]+)@([a-zA-Z0-9-])+(\.[a-zA-Z0-9-]+)+$;
 if (eregi($reg, $str)) {
  return true;//-- good email
  }else{
  return false;//--bad email
  }
   }//--close function
 
   Thanks in advance for any comments or help.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Find invalid email formats using MySQL query.

2006-05-20 Thread Peter Brawley




Yesmin Patwary wrote:

  Dear All,
   
  My contact table has email field which contains many invalid email addresses. I find them using following php function.  Is there a way to do that check in MySQL query?
   
  function emailValidate ($str)
 {
$reg = "^([a-zA-Z0-9._-]+)@([a-zA-Z0-9-])+(\.[a-zA-Z0-9-]+)+$";
if (eregi($reg, $str)) {
 return true;//-- good email
 }else{
 return false;//--bad email
 }
  }//--close function
  

Works if you change \. to [.period.].

PB

-

  
  Thanks in advance for any comments or help.

		
-
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates starting at 1cent;/min.
  
  

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.6.1/344 - Release Date: 5/19/2006
  



No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.6.1/344 - Release Date: 5/19/2006


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

RE: Find invalid email formats using MySQL query.

2006-05-20 Thread fbsd
You need to use a stronger edit to check email addresses.
This is what I use. Note the dns mx domain name check.

$len = 0,45;
if (empty ($email))
 { $errors[] = font color=redYou didn't enter a Email
Address./font; }
elseif (!ereg(^([[:alnum:]\.\_\-]+)([EMAIL PROTECTED]:alnum:]\.\-]+\.+),
$email))
   { $errors[] = font color=redEmail Address format is
invalid. It must be
 this format [EMAIL PROTECTED]/font;
 $errors[] = font color=redAlpha-Numeric characters
plus - and . and _
  and @ are valid in the address./font; }
  else
{ // good email address so far now check for good dns mx for
domain name
  list($Username, $Domain) = split(@,$email);
  if(!getmxrr($Domain, $MXHost))
 { $errors[] = font color=redEmail Address Domain
name is invalid because
   it has no DNS mx records./font;}


As far as I know there is no way to do this in a query command. You
have to read every row's email field and then process against the
php code to check/validate followed by a DB delete for all bad ones.

Far better to fix code that edits the email field before adding it
to db.
Denying bad field content before adding it is the normal way this is
done.

-Original Message-
From: Yesmin Patwary [mailto:[EMAIL PROTECTED]
Sent: Saturday, May 20, 2006 10:48 AM
To: mysql@lists.mysql.com
Subject: Find invalid email formats using MySQL query.


Dear All,

  My contact table has email field which contains many invalid email
addresses. I find them using following php function.  Is there a way
to do that check in MySQL query?

  function emailValidate ($str)
 {
$reg = ^([a-zA-Z0-9._-]+)@([a-zA-Z0-9-])+(\.[a-zA-Z0-9-]+)+$;
if (eregi($reg, $str)) {
 return true;//-- good email
 }else{
 return false;//--bad email
 }
  }//--close function

  Thanks in advance for any comments or help.


-
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.
Great rates starting at 1cent;/min.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: Find invalid email formats using MySQL query.

2006-05-20 Thread Keith Roberts
Probably the most efficient place to do this sort of field 
checking would be using javascript in the browser. That 
would stop the bad addresses even being sent down the line 
to the server in the first place.

Keith

In theory, theory and practice are the same;
in practice they are not.

On Sat, 20 May 2006, fbsd wrote:

 To: Yesmin Patwary [EMAIL PROTECTED], mysql@lists.mysql.com
 From: fbsd [EMAIL PROTECTED]
 Subject: RE: Find invalid email formats using MySQL query.
 
 You need to use a stronger edit to check email addresses.
 This is what I use. Note the dns mx domain name check.
 
 $len = 0,45;
 if (empty ($email))
  { $errors[] = font color=redYou didn't enter a Email
 Address./font; }
 elseif (!ereg(^([[:alnum:]\.\_\-]+)([EMAIL PROTECTED]:alnum:]\.\-]+\.+),
 $email))
{ $errors[] = font color=redEmail Address format is
 invalid. It must be
  this format [EMAIL PROTECTED]/font;
  $errors[] = font color=redAlpha-Numeric characters
 plus - and . and _
   and @ are valid in the address./font; }
   else
 { // good email address so far now check for good dns mx for
 domain name
   list($Username, $Domain) = split(@,$email);
   if(!getmxrr($Domain, $MXHost))
  { $errors[] = font color=redEmail Address Domain
 name is invalid because
it has no DNS mx records./font;}
 
 
 As far as I know there is no way to do this in a query command. You
 have to read every row's email field and then process against the
 php code to check/validate followed by a DB delete for all bad ones.
 
 Far better to fix code that edits the email field before adding it
 to db.
 Denying bad field content before adding it is the normal way this is
 done.
 
 -Original Message-
 From: Yesmin Patwary [mailto:[EMAIL PROTECTED]
 Sent: Saturday, May 20, 2006 10:48 AM
 To: mysql@lists.mysql.com
 Subject: Find invalid email formats using MySQL query.
 
 
 Dear All,
 
   My contact table has email field which contains many invalid email
 addresses. I find them using following php function.  Is there a way
 to do that check in MySQL query?
 
   function emailValidate ($str)
  {
 $reg = ^([a-zA-Z0-9._-]+)@([a-zA-Z0-9-])+(\.[a-zA-Z0-9-]+)+$;
 if (eregi($reg, $str)) {
  return true;//-- good email
  }else{
  return false;//--bad email
  }
   }//--close function
 
   Thanks in advance for any comments or help.
 
 
 -
 Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.
 Great rates starting at 1cent;/min.
 
 
 -- 
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
 
 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: Find invalid email formats using MySQL query.

2006-05-20 Thread Chris Sansom

At 22:10 +0100 20/5/06, Keith Roberts wrote:

Probably the most efficient place to do this sort of field
checking would be using javascript in the browser. That
would stop the bad addresses even being sent down the line
to the server in the first place.


Sure, but if you're being conscientious about accessibility you have 
to allow for users without JavaScript, which means doing the test 
server-side as well.


--
Cheers... Chris
Highway 57 Web Development -- http://highway57.co.uk/

What contemptible scoundrel has stolen the cork to my lunch?
   -- W.C. Fields

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]