Jump to content

[SOLVED] getting only HOTMAIL users' emails and NOT Yahoo?


samoi

Recommended Posts

Hello guys!

 

I have users in my db, but I need to bring up only the hotmail users only and not any other users! from their emails!

 

So I went with this but I'm stuck !:

$SQL = 0 ; // the query to pull up the ALL emails!
while($row = mysql_fetch_row($SQL)) {//there are emails
$emails = preg_replace('/([\w-\.]+)@(hotmail).([a-zA-Z]{2,4}\.[a-zA-Z]{2,4}|[a-zA-Z]{2,4})/','\1@\2\3',$row[0]);

echo $emails;
}

 

 

 

Link to comment
Share on other sites

The OP didn't specify they wanted Hotmail.com e-mail addresses, they specified Hotmail addresses (which I assume would include .co.uk and any other variants, especially looking at the OPs Regex). Obviously you could use SELECT * FROM TABLE WHERE `email` LIKE '%hotmail%', but this would match an email address of hotmail_sucks@yahoo.com (prepare to be found by a spambot crawler if you own that address), which I assume is not wanted. Regex certainly seems the way forward.

Link to comment
Share on other sites

The OP didn't specify they wanted Hotmail.com e-mail addresses, they specified Hotmail addresses (which I assume would include .co.uk and any other variants, especially looking at the OPs Regex). Obviously you could use SELECT * FROM TABLE WHERE `email` LIKE '%hotmail%', but this would match an email address of hotmail_sucks@yahoo.com (prepare to be found by a spambot crawler if you own that address), which I assume is not wanted. Regex certainly seems the way forward.

 

RIGHT ON :P

 

SELECT * FROM table WHERE email REGEXP '[^@]+?@hotmail\.[a-z.]{2,5}'

Link to comment
Share on other sites

The OP didn't specify they wanted Hotmail.com e-mail addresses, they specified Hotmail addresses (which I assume would include .co.uk and any other variants, especially looking at the OPs Regex). Obviously you could use SELECT * FROM TABLE WHERE `email` LIKE '%hotmail%', but this would match an email address of hotmail_sucks@yahoo.com (prepare to be found by a spambot crawler if you own that address), which I assume is not wanted. Regex certainly seems the way forward.

 

RIGHT ON :P

 

SELECT * FROM table WHERE email REGEXP '[^@]+?@hotmail\.[a-z.]{2,5}'

 

That returns

 

ERROR 1139 (42000): Got error 'repetition-operator operand invalid' from regexp

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.