[PHP-DB] Function Problem

2003-12-02 Thread Chris Payne
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

[PHP-DB] Function problem???

2001-08-10 Thread Brian Grayless

Anybody know what might be wrong with this function?

My first version of the function was...

function Include_Lib($libFile)
{
include(LIB_DIR.$libFile);
}

but it didn't work so I simplied it...

function Include_Lib()
{
include(/path/generic_vars.phpi);
}
// Function call
Include_Lib();


and it still doesn't work? HELP!! I can't figure out what I'm missing???
I have this included in a file that is also included. Would that cause a
problem???

B R I A N   G R A Y L E S S
 Web Administrator
 Premier Resorts
 www.premier-resorts.com

 P: 435-655-4812
 F: 413-618-1518


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]