如何在PHP中使用Plupload进行insert语句

如何在PHP中使用Plupload进行insert语句,php,mysql,insert,plupload,Php,Mysql,Insert,Plupload,我有一个php程序包,可以将excel文件中的数据插入mysql数据库,但它不能处理大于4MB的文件,因为我无法访问php.ini文件,所以我想对insert语句进行分块。我找到了,但没有弄清楚如何将其用于insert语句。任何其他方法都可以 function insertRow($conn, $row, $header) { // find indexes // vorname $firstNameIndex = array_search('vorname', $header, true);

我有一个php程序包,可以将excel文件中的数据插入mysql数据库,但它不能处理大于4MB的文件,因为我无法访问php.ini文件,所以我想对insert语句进行分块。我找到了,但没有弄清楚如何将其用于insert语句。任何其他方法都可以

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/>";
}

}
函数insertRow($conn,$row,$header){
//查找索引
//沃名称
$firstNameIndex=array_search('vorname',$header,true);
//姓名/姓名
$lastNameIndex=array_search('name',$header,true);
如果($lastNameIndex==false)$lastNameIndex=array_search('nachname',$header,true);
//安雷德
$anredeIndex=数组搜索('anrede',$header,true);
//街头
$streetedex=arrayßu search('straße',$header,true);
//豪斯努默
$hausnummerIndex=array_search('hausnummer',$header,true);
//电传
$telefonIndex=array_search('telefon',$header,true);
//PLZ
$plzIndex=数组搜索('plz',$header,true);
//奥特
$ortIndex=数组搜索('ort',$header,true);
$anrede=$row[$anredeIndex];
$firstName=$row[$firstNameIndex];
$lastName=$row[$lastNameIndex];
$street=$row[$streetedex];
$houseNumber=$row[$hausnummerIndex];
$telefon=$row[$telefonIndex];
$plz=$row[$plzIndex];
$ort=$row[$ortIndex];
$title='unbekannt';
$geburtsdatum=0;
$hnr_zusatz=“”;
$timestamp=time();
$sql=错误;
打印(行);
回声“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
”; } }

我知道这一点都不安全,我对sql注入持开放态度,但在这之后我会改变这一点。提前感谢您。

如果您在这方面遇到困难,请立即修复SQL注入问题。如果这个习惯持续到“不安全”的代码之外,它可以节省你数小时的挫折感,如果不是潜在的话,那么你的职业生涯也会因此而受挫。你的服务器设置为什么?什么是PHP?提示:很多问题都可以通过PHP检测和解决,因此由简单错误导致的错误不容易被忽略。毫无例外,您必须密切关注返回值,其中许多表示您必须解决或向用户报告的问题。异常允许更复杂的流控制,因为它们可以“冒泡”到代码的其他部分,以便更方便地处理它们。您可以随时检查,即使无法更改它们。如果你不能改变这些,考虑使用像Amazon S3这样的对象商店来处理文件。当你上传超过4MB时会发生什么?你有什么错误吗?我认为您在读取4MB Excel文件时内存不足。