EmailList can be treated as a list with a cr/lf delimiter, if it's a
windows text file you can just use chr(10)

Something like ....


<cfloop list="#EmailList#" index="i" delimiters="#chr(10)#">
        <cfif len(i) gt 0 and find("@",i)>
        <cfquery datasource="dsn" name="whatever">
        INSERT into tblemails 
        (emailAddress)
        values
        ('#i#')
        </cfquery>
        </cfif>
</cfloop>

That's totally off the top of my head and hasn't been tested, but it's
not far off.

Good luck


-----Original Message-----
From: Luis Lebron [mailto:[EMAIL PROTECTED]] 
Sent: 18 December 2002 15:11
To: CF-Talk
Subject: Converting a php script to cf

I am trying to convert a php script that reads a text file with email
addresses (1 per line) and puts them in a database into a CF script.

Here's the original php code

PHP
$filename="master_email.txt";
$fp=fopen($filename, "r");
$EmailList = fread ($fp, filesize ($filename));

$EmailList = explode ("\n",$EmailList);
$EmailList=(array_unique($EmailList));
$count=count($EmailList);
print $count."<br>";
sort($EmailList);
 
foreach($EmailList as $email)
{
        if($email!="")
        {       
        $query="Insert into $table_name (email) values ('$email')";
        $result=&$conn->Execute($query); //Uses adodb db library
        print $email."<br>";
        }
}


Here's the CF code I have so far

CF
<cffile 
action = "read"
file = "C:\inetpub\wwwroot\intranet\master_email.txt"
variable = "EmailList" >
  

I'm new at this so any help would be greatly appreciated.


Luis R. Lebron
Project Manager
Sigmatech, Inc



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to