Hi there everyone,

This code works fine until I put it into my function, then it still works BUT however 
many lines are in the file are multiplied.  For example, if I have 3 lines with the 
following:

[EMAIL PROTECTED], myname
[EMAIL PROTECTED], yourname
[EMAIL PROTECTED], ourname

In THEORY this should just print the above, HOWEVER, when it's being called as a 
function it's giving me the following:

[EMAIL PROTECTED], myname
[EMAIL PROTECTED], myname
[EMAIL PROTECTED], myname
[EMAIL PROTECTED], yourname
[EMAIL PROTECTED], yourname
[EMAIL PROTECTED], yourname
[EMAIL PROTECTED], ourname
[EMAIL PROTECTED], ourname
[EMAIL PROTECTED], ourname

When it is inserted into the DB.  It might be something obvious, but here's the code 
below to see if there's anything obvious i'm doing wrong.

Oh and i've checked and $userfile AND $delim are being picked up ok.

function db_importcsv($userfile,$delim) {

if ($userfile == ""){
$failed = 'yes';
} else {

$date = date('d m Y');

$row = 1;
$handle = fopen ("$userfile","r");
 while ($data = fgetcsv ($handle, 5024, ",")) {
     $num = count ($data);
     $row++;

 mysql_query ("INSERT INTO emaillist (EMail,name,date) 
              VALUES ('$data[0]','$data[1]','$date')

 ");

};
fclose ($handle);

$failed = "no";

};

return $failed;
};

Any help would be really appreciated, as i'm new to functions but enjoying it :-)

Chris

Reply via email to