PHP pro's, got an interesting problem....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StuartD
    Sofa King Band
    • Jul 2002
    • 29903

    #1

    PHP pro's, got an interesting problem....

    I recently upgraded my PHP to 5.2.1 and now have an interesting problem.

    I have a query grabbing results from a database. The results then loop in a while loop and get dumped into an array for storage.

    The problem is, it worked before.... but now it dies out after it hits a certain point.

    I don't get any "out of memory" errors, it just.... stops.

    I know the code is ok, I can get results from other queries that don't return as much information, and it worked on 5.2.

    I bumped the memory usage to 100Mb in the ini file, and it still dies at the same point.

    Thoughts?
    This is me on facebook
    This is me on twitter
  • Adultnet
    Confirmed User
    • Sep 2003
    • 8713

    #2
    maybe its a time out server side ?


    TrafficCashGold Paying Webmasters Since 1996!

    Awesome Conversions! Fast Weekly Payments! Over 125 Tours!

    Comment

    • psili
      Confirmed User
      • Apr 2003
      • 5526

      #3
      Did you try:

      set_time_limit(0)

      ?

      Maybe it is a timeout somewhere.
      Your post count means nothing.

      Comment

      • StuartD
        Sofa King Band
        • Jul 2002
        • 29903

        #4
        Nah, it gives me a blank screen within 2-3 seconds. So it's dying out during the loop pretty fast.
        This is me on facebook
        This is me on twitter

        Comment

        • psili
          Confirmed User
          • Apr 2003
          • 5526

          #5
          I saw a post made today somewhere about drupal and php 5.2.1 not playing nice with each other - throwing memory errors or something. Not sure what it could be as you'd think a simple loop would run fine. Are you running it from command line or a browser?
          Your post count means nothing.

          Comment

          • Adultnet
            Confirmed User
            • Sep 2003
            • 8713

            #6
            Originally posted by StuartD
            Nah, it gives me a blank screen within 2-3 seconds. So it's dying out during the loop pretty fast.
            I guess the script page does not receive the variables of the query page.
            Try to check the code and look if the page variables are received with $_get or $_post since if this is not determined it might be the problem.


            TrafficCashGold Paying Webmasters Since 1996!

            Awesome Conversions! Fast Weekly Payments! Over 125 Tours!

            Comment

            • StuartD
              Sofa King Band
              • Jul 2002
              • 29903

              #7
              Originally posted by StuartD
              I know the code is ok, I can get results from other queries that don't return as much information, and it worked on 5.2.
              Originally posted by Adultnet
              I guess the script page does not receive the variables of the query page.
              Try to check the code and look if the page variables are received with $_get or $_post since if this is not determined it might be the problem.
              Thanks for the help though.
              This is me on facebook
              This is me on twitter

              Comment

              • StuartD
                Sofa King Band
                • Jul 2002
                • 29903

                #8
                Originally posted by psili
                I saw a post made today somewhere about drupal and php 5.2.1 not playing nice with each other - throwing memory errors or something. Not sure what it could be as you'd think a simple loop would run fine. Are you running it from command line or a browser?
                I run it from within the browser.

                I'm pretty sure it is a memory error, but like I said, I'm not getting the error. I turned on _ALL and even turned on the logging to throw errors to the apache error log and yet... I get nothing.

                Just a blank page in my browser where I should see results.
                This is me on facebook
                This is me on twitter

                Comment

                • woj
                  <&(©¿©)&>
                  • Jul 2002
                  • 47882

                  #9
                  wow, didn't even notice we are up to 5.2.1, seems like yesterday when 4.2.1 was out...
                  Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
                  Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
                  Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

                  Comment

                  • Adultnet
                    Confirmed User
                    • Sep 2003
                    • 8713

                    #10
                    Originally posted by StuartD
                    Thanks for the help though.
                    the code could work fine on your last version of php to increase security some defaults were changed and you might need to optimize your code or your php settings.
                    For best idea of what could be changed just review it at php.net


                    TrafficCashGold Paying Webmasters Since 1996!

                    Awesome Conversions! Fast Weekly Payments! Over 125 Tours!

                    Comment

                    • Nookster
                      Confirmed IT Professional
                      • Nov 2005
                      • 3744

                      #11
                      try it from the command line, if it doesn't work there than there was a problem with the installation so you'll need to re-install. If it works then it's your software. Doesn't anyone know how to use trial and error these days?
                      The Best Affiliate Software, Ever.

                      Comment

                      • Nookster
                        Confirmed IT Professional
                        • Nov 2005
                        • 3744

                        #12
                        Originally posted by Adultnet
                        the code could work fine on your last version of php to increase security some defaults were changed and you might need to optimize your code or your php settings.
                        For best idea of what could be changed just review it at php.net
                        And yes, that could also be the issue.
                        The Best Affiliate Software, Ever.

                        Comment

                        • StuartD
                          Sofa King Band
                          • Jul 2002
                          • 29903

                          #13
                          Originally posted by Nookster
                          try it from the command line, if it doesn't work there than there was a problem with the installation so you'll need to re-install. If it works then it's your software. Doesn't anyone know how to use trial and error these days?
                          Thanks for your wonderful insight, but yes, I did try it and I still have the same problem, and yes I have re-installed and yes, the loop works 1200 times before it just stops so using $_GET most likely isn't the problem... no matter what new security features there are.

                          Doesn't anyone use common sense these days?
                          This is me on facebook
                          This is me on twitter

                          Comment

                          • Damian_Maxcash
                            So Fucking Banned
                            • Oct 2002
                            • 12745

                            #14
                            Damn - this came up on a WP forum I was looking at the other day.

                            I will have a search through my history, but it could have been on my laptop that I have loaned out.

                            I will get back to you.

                            Comment

                            • jimbona
                              Confirmed User
                              • Jan 2007
                              • 190

                              #15
                              Doing some searching via google, shows many people are suffering from memory leaks on heavy array use, you can see the changes of the PHP core here

                              php.net/ChangeLog-5.php
                              (sorry could not post url)

                              You may want to provide some sample code so people can advise/test locally what is failing.

                              Have you tried checking if anything has changed in your PHP setup with a phpinfo.php page with
                              PHP Code:
                              <?php phpinfo();?>
                              inside.
                              You can also try putting errors on in php.ini or via .htaccess.

                              When you get a white page straight away it usally means a code error has taken place so seeing the code could route out the problem. Just because you are using similar code else where and it works, doesnt mean this version does. You could have a rogue .,'" etc etc.
                              Thanks
                              Paul
                              Thunder-Ball.net - Member

                              Comment

                              • StuartD
                                Sofa King Band
                                • Jul 2002
                                • 29903

                                #16
                                Originally posted by jimbona
                                Doing some searching via google, shows many people are suffering from memory leaks on heavy array use, you can see the changes of the PHP core here


                                (sorry could not post url)

                                You may want to provide some sample code so people can advise/test locally what is failing.

                                Have you tried checking if anything has changed in your PHP setup with a phpinfo.php page with
                                PHP Code:
                                <?php phpinfo();?>
                                inside.
                                You can also try putting errors on in php.ini or via .htaccess.

                                When you get a white page straight away it usally means a code error has taken place so seeing the code could route out the problem. Just because you are using similar code else where and it works, doesnt mean this version does. You could have a rogue .,'" etc etc.
                                this is the code:

                                PHP Code:
                                while($line = mysql_fetch_array($result, MYSQL_ASSOC)){
                                    $list[] = $line;
                                } 
                                
                                I figured it was a code error at first, because of the white page. However, as I said, if I throw in an output... it'll give me 1200 lines or so before it stops outputting... .without giving an error. It just ends the while statement and then won't output anything following the loop either.

                                And my phpinfo() looks the same from what I could see. I tried to keep all my settings the same.
                                This is me on facebook
                                This is me on twitter

                                Comment

                                • Tempest
                                  Too lazy to set a custom title
                                  • May 2004
                                  • 10217

                                  #17
                                  There's been a lot of problems with 5.2.. thankfully 5.2.1 fixed my biggest problem but I'm sure there's more...

                                  I see you have all the logs turned on.. Have you confirmed that it would report an error by "forcing" one in your mysql query? I've been having a lot of issues with my queries where I didn't before so would be interested to know if the query actually works or fails and that the problem is after that.

                                  Comment

                                  • jimbona
                                    Confirmed User
                                    • Jan 2007
                                    • 190

                                    #18
                                    Hi,

                                    If it is writing 1200 lines a failing, have your tried running a similar query along through PHPmyadmin or similar to see if any of the fields you are pulling are empty.

                                    Do you do any outputting in the page?

                                    try putting in some checking

                                    i.e.

                                    PHP Code:
                                    while($line = mysql_fetch_array($result, MYSQL_ASSOC)){ 
                                        if(!empty($line))
                                        {
                                            $list[] = $line;
                                        }
                                    } 
                                    
                                    can you also show a dummy of what $result it?
                                    What type of field/size are you pulling into the array?
                                    Thanks
                                    Paul
                                    Thunder-Ball.net - Member

                                    Comment

                                    • HomeFry
                                      Confirmed User
                                      • Jun 2006
                                      • 1062

                                      #19
                                      It sounds like your MySQL database has alzheimers.
                                      Need Mushrooms Designed? Gimme-Website

                                      Comment

                                      • StuartD
                                        Sofa King Band
                                        • Jul 2002
                                        • 29903

                                        #20
                                        Originally posted by jimbona
                                        Hi,

                                        If it is writing 1200 lines a failing, have your tried running a similar query along through PHPmyadmin or similar to see if any of the fields you are pulling are empty.

                                        Do you do any outputting in the page?

                                        try putting in some checking

                                        i.e.

                                        PHP Code:
                                        while($line = mysql_fetch_array($result, MYSQL_ASSOC)){ 
                                            if(!empty($line))
                                            {
                                                $list[] = $line;
                                            }
                                        } 
                                        
                                        can you also show a dummy of what $result it?
                                        What type of field/size are you pulling into the array?
                                        That checking is a good idea, however it still blanks out the page if it goes too many rows.

                                        I checked and the mysql_num_rows tells me that there's 2900+ results. So it's pulling the data properly... it's all there.

                                        However once I start looping it and putting it into the array, it dies.

                                        If I alter the code to just output the fields in $line, it outputs everything quite nicely.

                                        It's dumping the information into the array that causes it to choke out.
                                        This is me on facebook
                                        This is me on twitter

                                        Comment

                                        • Damian_Maxcash
                                          So Fucking Banned
                                          • Oct 2002
                                          • 12745

                                          #21
                                          Originally posted by StuartD
                                          That checking is a good idea, however it still blanks out the page if it goes too many rows.

                                          I checked and the mysql_num_rows tells me that there's 2900+ results. So it's pulling the data properly... it's all there.

                                          However once I start looping it and putting it into the array, it dies.

                                          If I alter the code to just output the fields in $line, it outputs everything quite nicely.

                                          It's dumping the information into the array that causes it to choke out.
                                          I know you have already checked this, but just in case - whats max_execution_time in php.ini?

                                          Have you got safe mode on or off?

                                          Obvious stuff - but I have missed it before on a new server.

                                          Comment

                                          • StuartD
                                            Sofa King Band
                                            • Jul 2002
                                            • 29903

                                            #22
                                            Originally posted by damian2001
                                            I know you have already checked this, but just in case - whats max_execution_time in php.ini?

                                            Have you got safe mode on or off?

                                            Obvious stuff - but I have missed it before on a new server.
                                            60 seconds, tried changing it in the code to 0 and to 999... neither helped.

                                            And safe mode is turned off.

                                            Good thinking. I hadn't actually checked to see about safe mode, just assumed... but now that you mentioned it, I checked just to be sure.
                                            This is me on facebook
                                            This is me on twitter

                                            Comment

                                            • jimbona
                                              Confirmed User
                                              • Jan 2007
                                              • 190

                                              #23
                                              Hi,

                                              try doing

                                              PHP Code:
                                              while($line = mysql_fetch_array($result, MYSQL_ASSOC)){  
                                                  if(!empty($line)) 
                                                  { 
                                                      $list[] = $line; 
                                                      echo $line."<br>";
                                                  } 
                                              } 
                                              
                                              or
                                              PHP Code:
                                              while($line = mysql_fetch_array($result, MYSQL_ASSOC)){  
                                                  if(!empty($line)) 
                                                  { 
                                                      $list[] = $line; 
                                                  } 
                                              }  
                                              print_r($list); 
                                              
                                              See what is last in the line and find out the value after it.
                                              What type of data are you dumping? String?, links? string lengths?

                                              If you want to PM me I could have a direct look if needed to help debug it, im just interested in what would cause such an issue. :/
                                              Thanks
                                              Paul
                                              Thunder-Ball.net - Member

                                              Comment

                                              • StuartD
                                                Sofa King Band
                                                • Jul 2002
                                                • 29903

                                                #24
                                                Ok, I found it... took me forever though!

                                                php 5.2.1 put in a second php.ini file.... one in the php folder and one in the apache folder.

                                                The new one had a memory limit of 8, but it was reporting what I saw in the other php.ini.

                                                And therefore, my memory limit was way lower than I thought it was. Once I changed the second php.ini file, all was good!


                                                Thank you to everyone for helping me to solve this
                                                This is me on facebook
                                                This is me on twitter

                                                Comment

                                                • psili
                                                  Confirmed User
                                                  • Apr 2003
                                                  • 5526

                                                  #25
                                                  Originally posted by StuartD
                                                  Ok, I found it... took me forever though!

                                                  php 5.2.1 put in a second php.ini file.... one in the php folder and one in the apache folder.

                                                  The new one had a memory limit of 8, but it was reporting what I saw in the other php.ini.

                                                  And therefore, my memory limit was way lower than I thought it was. Once I changed the second php.ini file, all was good!


                                                  Thank you to everyone for helping me to solve this

                                                  I've had the stupid issue happen to me and it drove me crazy where a "ghost" php.ini file existed somewhere. Since then, I try and remind myself to check php_info() and make sure shit's where I think it should be.
                                                  Your post count means nothing.

                                                  Comment

                                                  • borked
                                                    Totally Borked
                                                    • Feb 2005
                                                    • 6284

                                                    #26
                                                    Originally posted by StuartD
                                                    Ok, I found it... took me forever though!

                                                    php 5.2.1 put in a second php.ini file.... one in the php folder and one in the apache folder.

                                                    The new one had a memory limit of 8, but it was reporting what I saw in the other php.ini.

                                                    And therefore, my memory limit was way lower than I thought it was. Once I changed the second php.ini file, all was good!


                                                    Thank you to everyone for helping me to solve this
                                                    Glad you got it sorted - I also had a major prob with the 5.2.1 upgrade - as it turned out, the upgrade rearranged the order of loaded extensions and putting mysql.so and pspell.so as the last to load fixed the pb. (took me a while to fix that one!)

                                                    For coding work - hit me up on andy // borkedcoder // com
                                                    (consider figuring out the email as test #1)



                                                    All models are wrong, but some are useful. George E.P. Box. p202

                                                    Comment

                                                    Working...