Re: Split email addresses
| From: | Andy Woolley | Date: | Thu, 12 Oct 2000 11:56:05 +0000 |
| Subject: | Re: Split email addresses | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-34769@lists.php.net to get a copy of this message | ||
Best to write a script in PHP to dump your data into MySQL.
1. open text file.
2. populate array with values seperated by end of line marker (\n)
3. loop through array creating insert query
4. execute query
5. loop through the above until complete
some code for you.
*****************************************
mysql_connect ("127.0.0.1","USER","PASSWORD");
mysql_selectdb("yourdatabase");
$emailstring = fopen("yourtextfile.txt", "r");
$emailarray = split("\n", $emailstring); #this puts emails in an array
for (x=0; x < count($emailarray); x++)
{
$email = $emailarray[$x];
$newarray = split("@", $email);
$insertquery = "insert into NEWUSERS set name=\"$newarray[0]\",
mailserver = \"$newarray[1]\",
$qry = mysql_query($insertquery);
}
*****************************************
Hope this helps
Andy Woolley
M.D.
www.databasewatch.com
----- Original Message -----
From: "I G" <hungama_in_underwear@yahoo.com>
To: "Andy Woolley" <andy@milonic.com>
Cc: "php-dev" <php-dev@lists.php.net>; <mysql@lists.mysql.com>
Sent: Saturday, October 14, 2000 12:32 PM
Subject: Re: Split email addresses
> OK
>
> i got that can u do one more favour i have checked with 1 email its
working
> what if we have multiple email address. one email address in one line in a
.txt
> file how to insert that....
>
> OR
>
> Should store all the email addresses as array (, (comma limited)).... can
u pls
> help
>
> 'coz before i converted my home page to php3/mysql driven... it was
cgi/perl
> enabled to store email addresses to a plain txt file one record in one
line now
> i want to put all my database into mysql table so my friends don't have to
> re-register again....
>
> Pls help
>
>
>
> Andy Woolley wrote:
>
> > ***************************
> > $email = "guest@aol.com";
> > $newarray = split("@", $email);
> > echo $newarray[0]; # will isplay "guest"
> > echo $newarray[1]; # will display "@aol.com"
> > ***************************
> >
> > Or something like that, try it and see what happens.
> >
> > Regards
> >
> > Andy Woolley
> > M.D.
> > www.databasewatch.com
> >
> > ----- Original Message -----
> > From: "I G" <hungama_in_underwear@yahoo.com>
> > To: "php-dev" <php-dev@lists.php.net>; <mysql@lists.mysql.com>
> > Sent: Saturday, October 14, 2000 11:07 AM
> > Subject: Split email addresses
> >
> > > Hi
> > > is there any way by which i can split an email address into two
> > > variables like
> > > email address: guest@aol.com
> > >
> > > variable1 = "guest"
> > > variable2 = "@aol.com"
> > >
> > > and then insert it into mysql database using php3
> > > username = "guest"
> > > domain name = "@aol.com"
> > > email = "guest@aol.com"
> > >
> > > can you pls help or is there any example available
> > >
> > >
> > > --
> > > ---------------------------------------------------------------------
> > > Please check
> > > "http://www.mysql.com/documentation/manual.php" before
> > > posting. To request this thread, e-mail
mysql-thread53052@lists.mysql.com
> > >
> > > To unsubscribe, send a message to:
> > > <mysql-unsubscribe-andy=milonic.com@lists.mysql.com>
> > >
> > > If you have a broken mail client that cannot send a message to
> > > the above address (Microsoft Outlook), you can use:
> > > http://lists.mysql.com/php/unsubscribe.php
> > >
> > >
> >
> > --
> > ---------------------------------------------------------------------
> > Please check
> > "http://www.mysql.com/documentation/manual.php" before
> > posting. To request this thread, e-mail
mysql-thread53056@lists.mysql.com
> >
> > To unsubscribe, send a message to:
> > <mysql-unsubscribe-hungama_in_underwear=yahoo.com@lists.mysql.com>
> >
> > If you have a broken mail client that cannot send a message to
> > the above address (Microsoft Outlook), you can use:
> > http://lists.mysql.com/php/unsubscribe.php
>
>
> --
> ---------------------------------------------------------------------
> Please check
> "http://www.mysql.com/documentation/manual.php" before
> posting. To request this thread, e-mail mysql-thread53061@lists.mysql.com
>
> To unsubscribe, send a message to:
> <mysql-unsubscribe-andy=milonic.com@lists.mysql.com>
>
> If you have a broken mail client that cannot send a message to
> the above address (Microsoft Outlook), you can use:
> http://lists.mysql.com/php/unsubscribe.php
>
>