0

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?

10
  • 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 ram Commented 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. Commented Jan 6, 2013 at 0:19
  • what about ignore_user_abort ? Commented Jan 6, 2013 at 0:21
  • I set it to false, no help. Commented Jan 6, 2013 at 0:23
  • khmm....what apache error log says to you ? what about error_reporting inside your php script Commented Jan 6, 2013 at 0:24

5 Answers 5

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I set set_time_limit to 5000 then 0, no help. My script only takes 5 seconds to load.
1

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

1

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

1 Comment

I set set_time_limit to 5000 then 0, no help. My script only takes 5 seconds to load.
0

check "max_execution_time"

How long does the script run before breaking? 30 seconds?

Comments

0

Use set_time_limit() and increase the max execution time for the script.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.