I have not yet found a solution to this. I was using memory_limit to remove the error but it still doesn't insert all records into the database. I have 20K records.
Here is the error I get
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in C:\xampp\htdoc\a\b\excel_reader.php on line 1367
Any ideas on how to fix it?
Here's the code:
ini_set('memory_limit', '512M');
$format_file = $_POST['fileexcel'];
$format_file = $_FILES['fileexcel']['tmp_name'];
if (strlen($format_file)<1){
echo "empty file";
exit();
}
$data = new Spreadsheet_Excel_Reader($format_file);
$result = $data->rowcount($sheet_index=0);
for ($i=2; $i<=$result; $i++){
$data1 = $data->val($i,1);
$data2 = $data->val($i,5);
$data3 = $data->val($i,10);
$q = mysql_query("INSERT INTO t (k,m,n) VALUES ('$data1','$data2','$data3')") or die(mysql_error());
if ($result) {
echo "success";
}
else {
echo "failed";
}
}