The below script will parse a csv file to a database I need to remove
the first line because it is the header files and I don't need them. How can
I test for that and remove them.
$file = fopen($_POST['copy'], 'r') or $message .= "Could not open" .
$_POST[copy] . "for reading.<BR>\n";
while (!feof($file)){
# We could easily be importing 10,000 records. Give us
some time here, okay?
set_time_limit(30);
$fields = fgetcsv($file, 1000000);
if ($fields && count($fields)){
$recordcount++;
# Wipe out every possible field, in case they have
some missing:
reset($possiblefields);
while (list(,$fieldname) = each($possiblefields)){
$$fieldname = '';
}
reset($_POST['fieldorder']);
$fieldcount = 0;
$notes = '';
while (list(,$field) = each($fields)){
$fieldname =
$_POST['fieldorder'][$fieldcount++];
if ($fieldname == 'notes'){
$notes .= addslashes("$field\n");
}
elseif ($fieldname == '-- ignore --'){
# ignore it
}
else{
# Note that file data is not Magic-Quoted:
$$fieldname = addslashes($field);
}
}
require 'importinsert.php';
}