Answer the question
In order to leave comments, you need to log in
How to fix the out of memory allocated 1404829696 error?
when writing data to excel using php, it gives an error out of memory (allocated 1404829696). I tried to add ini_set (), changed php.ini but everything exactly gives such an error
Answer the question
In order to leave comments, you need to log in
memory is clogged, you need to clean up the value of variables. but because to litter so much memory, you still have to manage, which means most likely you have an eternal cycle there somewhere or some kind of array grows exponentially.
How much data are you trying to write? PhpExcel is a very gluttonous thing, it might be worth writing in parts, you also need to check the code for what shaks said
regular topic. only I had such a joke with ms sql. I remember explicitly specifying column types. and you feel free to write how you overcame the problem
$i = 0;
$file_name = 'xls/Spisok.xls';
$file_name1 = 'xls/Spisok1.xls';
require_once 'classes/PHPExcel.php';
$phpexcel = PHPExcel_IOFactory::load($file_name);
$page = $phpexcel->setActiveSheetIndex(0);
$query = 'SELECT * FROM list';
$result = pg_query($query) or die('Zaprosda muammo: ' . pg_last_error());
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
$j = $i+2;
$page->setCellValueByColumnAndRow(0,$j,$line4["p_id"]);
$page->setCellValueByColumnAndRow(1,$j,$line4["surname"]);
$page->setCellValueByColumnAndRow(2,$j,$line4["name"]);
$page->setCellValueByColumnAndRow(3,$j,$line4["middlename"]);
$page->setCellValueByColumnAndRow(4,$j,$line4["adress"]);
if (isset($_POST["c5"]) && (!empty($_POST["c5"]))){
$page->setCellValueByColumnAndRow(5,$j,$line4["birth"]);
}
if (isset($_POST["c6"]) && (!empty($_POST["c6"]))){
$page->setCellValueByColumnAndRow(6,$j,$line4["sex"]);
}
if (isset($_POST["c7"]) && (!empty($_POST["c7"]))){
$page->setCellValueByColumnAndRow(7,$j,$line4["nationality"]);
}
if (isset($_POST["c8"]) && (!empty($_POST["c8"]))){
$page->setCellValueByColumnAndRow(8,$j,$line4["marital"]);
}
$i=$i+1;
}
$objWriter = PHPExcel_IOFactory::createWriter($phpexcel, 'Excel2007');
$objWriter->save($file_name1);
pg_free_result($result);
pg_close($conn);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question