I have PHP script contains a long loop to list about 60,000 email addresses from mysql, but after 30,000, my php script stops working and brakes, and sometimes all php script is written in white page (my page has imaged background), I increased PHP memory limit to unlimited, but no help. What's problem?
-
As other users said - try "max_execution_time", if it not help - it can be memory issue. Try to output memory_get_usage on every 1000 iteration and compare with your server ramkirugan– kirugan2013-01-05 22:34:21 +00:00Commented Jan 5, 2013 at 22:34
-
I set set_time_limit to 5000 then 0, no help Last number I got after 33,138th email address is 332032 bytes (325 kb), my server has 2GB RAM.Houranis– Houranis2013-01-06 00:19:53 +00:00Commented Jan 6, 2013 at 0:19
-
what about ignore_user_abort ?kirugan– kirugan2013-01-06 00:21:15 +00:00Commented Jan 6, 2013 at 0:21
-
I set it to false, no help.Houranis– Houranis2013-01-06 00:23:30 +00:00Commented Jan 6, 2013 at 0:23
-
khmm....what apache error log says to you ? what about error_reporting inside your php scriptkirugan– kirugan2013-01-06 00:24:40 +00:00Commented Jan 6, 2013 at 0:24
5 Answers
The default execution time limit is 30 seconds, or the *max_execution_time* value from php.ini. Is your script taking longer than that? If so, you can increase the limit with set_time_limit.
The better question is, what are you doing with 60,000 email addresses that is taking so long? Chances are, there is a much better way to do whatever is taking too long.
1 Comment
There are two things you can try here. Firstly, set_time_limit(0). Setting it to zero means there is essentially no time limit.
Secondly you might want to use ignore_user_abort(false). This will et whether a client disconnect should abort script execution.
Both will ensure that your script keeps running for as long as it needs... or until your server packs out :)
Comments
The problem is not in memory I think it's in Time for execution
set_time_limit(VERY_BIG_NUMBER);
Update:
add
ini_set("display_errors","on");
error_reporting(E_ALL);
and inspect errors if any