I have this function to insert some data in my mysql database:
function insertRow($conn, $row, $header) {
// find indexes
// vorname
$firstNameIndex = array_search('vorname', $header, true);
// name / nachname
$lastNameIndex = array_search('name', $header, true);
if($lastNameIndex === false) $lastNameIndex = array_search('nachname', $header, true);
// anrede
$anredeIndex = array_search('anrede', $header, true);
// street
$streetIndex = array_search('straße', $header, true);
// Hausnummer
$hausnummerIndex = array_search('hausnummer', $header, true);
// Telefon
$telefonIndex = array_search('telefon', $header, true);
// PLZ
$plzIndex = array_search('plz', $header, true);
// ORT
$ortIndex = array_search('ort', $header, true);
$anrede = $row[$anredeIndex];
$firstName = $row[$firstNameIndex];
$lastName = $row[$lastNameIndex];
$street = $row[$streetIndex];
$houseNumber = $row[$hausnummerIndex];
$telefon = $row[$telefonIndex];
$plz = $row[$plzIndex];
$ort = $row[$ortIndex];
$title = 'unbekannt';
$geburtsdatum = 0;
$hnr_zusatz = "";
$timestamp = time();
$sql = <<<EOSQL
INSERT INTO adressen (anrede, vorname, nachname, strasse, hnr, telefon1, id_lieferung, priv_gew,
status, titel, geburtsdatum, hnr_zusatz, plz, ort, telefon2, mail, sperrung, sperrgrund, optin,
optindat, timestamp, zusatz1) VALUES ("$anrede", "$firstName", "$lastName", "$street",
"$houseNumber", "$telefon", 0, 0, 0, "$title", $geburtsdatum, "$hnr_zusatz", "$plz", "$ort", 0, "",
0, 0, 0, 0, $timestamp, 0);
EOSQL;
if (!$conn->query($sql) === TRUE) {
echo "Error: cant add this row " . $sql . "<br/>" . $conn->error;
print_r($row);
echo "___________________<br/>";
}
}
It works for small data but when I try it with a file more than 4 MB it doesn't work. I do not have access to the php.ini file sadly. These inserts come originally from an excel file. I wanted to try plupload but didn't understand how to implement it to my method.