#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    231
    Rep Power
    0

    PHP while loop issue


    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 and set max_execution_time to 0, but no help.

    My server has 2GB RAM.

    What's problem?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    Maybe try breaking it up by limiting 0-10000 uthen do 10001-20000 etc using limit. I'm not sure but maybe beyond the maximum size of an array to load the results of the query in. Could be wrong and I'm sure a more experienced member will correct me.
    Originally Posted by Penicillin
    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 and set max_execution_time to 0, but no help.

    My server has 2GB RAM.

    What's problem?
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,301
    Rep Power
    7170
    The first step in fixing a problem is always to figure out what the problem is. It sounds like you have error reporting turned off. Look in the FAQ for several methods of turning it on. Once you've done that, you should get a useful error message when you run the script that will tell you what is going wrong.

    It's possible that the script is running out of memory.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    231
    Rep Power
    0
    Originally Posted by E-Oreo
    The first step in fixing a problem is always to figure out what the problem is. It sounds like you have error reporting turned off. Look in the FAQ for several methods of turning it on. Once you've done that, you should get a useful error message when you run the script that will tell you what is going wrong.

    It's possible that the script is running out of memory.
    error reporting is on, and it shows no errors for today.

    Anyway, I changed my while loop to save email addresses in one text file using fwrite, and prints nothing in my php page, and this one is working for me, I got all emails in text file.
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,918
    Rep Power
    1045
    Um, why are you trying to print 60,000 raw email addresses, anyway?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    231
    Rep Power
    0
    Originally Posted by Jacques1
    Um, why are you trying to print 60,000 raw email addresses, anyway?
    Because I wanted to copy then paste them in my mailing list, mailing list is in a separate server, but I noticed that it accepts text file containing email addresses.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    SF Bay Area, California
    Posts
    2
    Rep Power
    0
    Originally Posted by Jacques1
    Um, why are you trying to print 60,000 raw email addresses, anyway?
    LOL! That was my first question too! I was thinking, "definitely not going to help a spammer"

    Sounds like your server is timing out. Breaking it up is the easiest way. 60,000 emails don't take up 2gb of ram (although I hope this server isn't used for anything major with only 2gb of ram).

    Breaking it up into 10,000s would help a lot, but (12) 5,000 runs would be HELLA faster. From my experience, it seems that after about 6-7k things start getting jankie.

    Split it up, recompile on the receiving end and all will go well. (oh yeah, and buy some more ram, it's cheap now. )
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    ill keep this guy in mind next time i get an email from the prince of south africa :P
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    231
    Rep Power
    0
    Originally Posted by MSHax
    LOL! That was my first question too! I was thinking, "definitely not going to help a spammer"

    Sounds like your server is timing out. Breaking it up is the easiest way. 60,000 emails don't take up 2gb of ram (although I hope this server isn't used for anything major with only 2gb of ram).

    Breaking it up into 10,000s would help a lot, but (12) 5,000 runs would be HELLA faster. From my experience, it seems that after about 6-7k things start getting jankie.

    Split it up, recompile on the receiving end and all will go well. (oh yeah, and buy some more ram, it's cheap now. )
    LOL, I'm not a spammer, I have my own forum with about 60,000 subscribers, and I want to send them new news, and also there is a link to unsubscribe.

IMN logo majestic logo threadwatch logo seochat tools logo