/    Sign up×
Community /Pin to ProfileBookmark

Adding list of emails to database

I have an incredibly large list of emails (About 100k) that needs to be entered into a database.

I’ve been using PHP for a little while now but I haven’t really touched any of the stuff dealing with reading files; I’m thinking I could read the file until I encounter a .com/.ca/etc. then throw that into a variable and add it to the database (That system is already in place) then read until the next .com/.ca/etc. and move through the list like that, I’m just not sure what the syntax would be for that.

Does anyone have any idea how to do this?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@pcthugAug 29.2006 — How is the data stored?

Please post a sample of your data.
Copy linkTweet thisAlerts:
@EbolaauthorAug 29.2006 — It is stored in a .txt file, there is one email per line with a space at the front, like this:

[email][email protected][/email]

[email][email protected][/email]

[email][email protected][/email]

[email][email protected][/email]
Copy linkTweet thisAlerts:
@pcthugAug 29.2006 — PHP:[code=php]
<?php

mysql_connect('localhost', 'user', 'pass') or die(mysql_error());
mysql_select_db('db_name') or die(mysql_error());

$lines = file('email_flatfile_db.txt');
$emails = "";

foreach($lines as $line => $email) {
$emails .= "'".substr($email, 1)."',";
}

mysql_query("INSERT_INTO email_db VALUES ($emails 'test_record')") or die(mysql_error());

?>[/code]
Database Structure:
+----------+
| email_db |
+----------+
| field1 |
+----------+
×

Success!

Help @Ebola spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...