duncanb7
asked on
Fatal error on file_put_contents() NOT related memory_limt, execution time, input_time in php
Dear Experts,
I get one php script, csvextract.php, as attached in code area, and I found the error message
"Fatal Error: Out of memory(allocated 3123000)(tried to allocate 71 bytes) in /home/.../csvextract.php line 17"
at the line 17 is exactly at file_put contents() function location.
And I already check my php.ini file and .htaccess file, those are already setting correct memory_limit=128M,
max_execution_time=0, max_input_time=-1, so I believe the error message is NOT related to
memory_limit, max_input_time, max_exexcution_time.
SO what other factors or setting in php.ini will affect the file_put_contents() function ? Is the fatal error
related to magic_quotes_sysbase() and magic_quotes_runtime() ? I got confused about how to use
magic_quotes_sysbase!
When I cut down the file of "data.csv" file size by half or number of row in the file by half,
it is passed and no any error message.So I suspect $csv variable to store the array from file() can NOT
be too much size. Do you think so.? Is there any setting in php.ini related to parsing variable size like $csv as follows
Be reminded my fatal error message is out of memory(allocated 3123000)(tried) and NOT "Allowed memory size 100k exhausted"
If memory_limit is not set correctly, it will report error like " Allowed memory size 100k exhausted" for example only
Please advise
Duncan
I get one php script, csvextract.php, as attached in code area, and I found the error message
"Fatal Error: Out of memory(allocated 3123000)(tried to allocate 71 bytes) in /home/.../csvextract.php line 17"
at the line 17 is exactly at file_put contents() function location.
And I already check my php.ini file and .htaccess file, those are already setting correct memory_limit=128M,
max_execution_time=0, max_input_time=-1, so I believe the error message is NOT related to
memory_limit, max_input_time, max_exexcution_time.
SO what other factors or setting in php.ini will affect the file_put_contents() function ? Is the fatal error
related to magic_quotes_sysbase() and magic_quotes_runtime() ? I got confused about how to use
magic_quotes_sysbase!
When I cut down the file of "data.csv" file size by half or number of row in the file by half,
it is passed and no any error message.So I suspect $csv variable to store the array from file() can NOT
be too much size. Do you think so.? Is there any setting in php.ini related to parsing variable size like $csv as follows
Be reminded my fatal error message is out of memory(allocated 3123000)(tried) and NOT "Allowed memory size 100k exhausted"
If memory_limit is not set correctly, it will report error like " Allowed memory size 100k exhausted" for example only
Please advise
Duncan
my csvextract.php
========================================
<?php
ini_set('max_execution_time', 0);
ini_set('max_input_time', -1);
ini_set('memory_limit', '128M');
ini_set('post_max_size', "128M");
ini_set('upload_max_filesize', "128M");
$csv=file("data.csv");
$e=count($csv);
$line=array();
for ($a=$e-1; $a > 0; --$a) {
$line= explode(",",$csv[$a]);
$line[4]=$line[4]+100;
$line[36]="a";
$line[37]="aa";
$line[38]="bb";
$line[39]="cc";
$line[40]="\n";
$csv= implode(",",$line);
}
file_put_contents("data.csv",$csv);
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If you keep answer this way, I will ask EE adm to stop your behaviour or account
ASKER
Any suggestion, please conside and read the thread title in detail before you making any comment
Oh you asking for help and threatening people at the same time? Good luck :-)
ASKER
If you think so, it is not, just hope you conside and read the thread title in detail before you making any fast comment
This is probably error returned from malloc which means that probably OS denied allocation. Why? Because your ulimit can be set to low numbers.
But I will not follow this thread anymore - you are very rude and need to learn how to work with people.
But I will not follow this thread anymore - you are very rude and need to learn how to work with people.
ASKER
Hope you can help and be serious to ask and write down what you are asking in detail at least more words for
other people to be understood
other people to be understood
ASKER
I am sorry to you and because I got a lot experience there is a lot of people who just play it aroud not serious.
please stay these thread and I will re-open this thread , your last thread is more kind and more show to others
that you are sincerely to help others because of more explaination.
I will follow your suggestion no matter that is right and wrong because you are serious to reply this thread
please stay these thread and I will re-open this thread , your last thread is more kind and more show to others
that you are sincerely to help others because of more explaination.
I will follow your suggestion no matter that is right and wrong because you are serious to reply this thread
Hai,
use the below lines on top of ur pages
ini_set("user_agent","Mozi lla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
ini_set("max_execution_tim e", 0);
ini_set("memory_limit", "10000M");
use the below lines on top of ur pages
ini_set("user_agent","Mozi
ini_set("max_execution_tim
ini_set("memory_limit", "10000M");
ASKER
The file size of data.csv is just below 1meg byte only
ASKER
It is same as before if change to
ini_set("user_agent","Mozi lla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
ini_set("max_execution_tim e", 0);
ini_set("memory_limit", "10000M");
It seems the system not allow $csv is too big in memory from
file_put_contents("data.cs v",$csv);
ini_set("user_agent","Mozi
ini_set("max_execution_tim
ini_set("memory_limit", "10000M");
It seems the system not allow $csv is too big in memory from
file_put_contents("data.cs
ASKER
Dear Adm,
Please help to reactivate this thread and I get the final answer to this thread
Please help to reactivate this thread and I get the final answer to this thread
ASKER
Dear Ali,
I am sorry I misundstood your
writing or meaning. Finally
it proved your reply is correct
ulimit -a , and I have checked
the max locked memory is limited
by host company in this thread
as follow
https://www.experts-exchange.com/questions/27052240/Out-of-memory-and-Cannot-allocate-more-memory-for-php-program-in-Linux-at-command-line.html
Anyway, thanks for your reply and
trigger to find out the final rea
son and answer
I am sorry I misundstood your
writing or meaning. Finally
it proved your reply is correct
ulimit -a , and I have checked
the max locked memory is limited
by host company in this thread
as follow
https://www.experts-exchange.com/questions/27052240/Out-of-memory-and-Cannot-allocate-more-memory-for-php-program-in-Linux-at-command-line.html
Anyway, thanks for your reply and
trigger to find out the final rea
son and answer
ASKER