3 Replies Latest reply on Jul 6, 2010 11:32 PM by NielsVDW

    Error while fetching more than 1000 mysql records

    NielsVDW

      I'm trying to fetch data from a MySQL database through PHP to a Flex application. When there are more than 1000 records in the resultset, the FaultEvent is returned. When I limit it to 1000 records, no problem at all. Any ideas? Code below:

       

      public function OldCustomerService(method:String=HTTPRequestMessage.POST_METHOD, resultFormat:String=RESULT_FORMAT_E4X, showBusyCursor:Boolean=true)
              {
                  super(null, null);
                  this.requestTimeout = 0;
                  this.method = method;
                  this.resultFormat = resultFormat;
                  this.showBusyCursor = showBusyCursor;
                 
                 
              }
             
              public function getAllProspects():void {
                  this.url = ALL_PROSPECTS_URL;
                  this.addEventListener(ResultEvent.RESULT, getAllProspectSuccess);
                  this.addEventListener(FaultEvent.FAULT, DAOUtil.communicationError);
                 
                  var oldCustomersToken:AsyncToken = this.send();
              }

        • 1. Re: Error while fetching more than 1000 mysql records
          Sebastien V. Level 3

          What is contained in the FaultEvent? Don't you have an error message in it?

           

          If you get a FaultEvent I would bet on an error caused by Php or MySql instead of Flex itself.

          • 2. Re: Error while fetching more than 1000 mysql records
            NielsVDW Level 1

            It's an XML syntax fault. But when I limit down the records, there is no problem. It seems the code can't handle the quantity of records. Also, the error comes instant. While in debug mode, I see all the records still popping up in the console. So it seems he isn't waiting until the full xml is created and therefor creates the XML syntax error.

            • 3. Re: Error while fetching more than 1000 mysql records
              NielsVDW Level 1

              It works with fewer records so it would be weird if it would be a php or mysql error. Seems to me Flex isn't waiting until everything is in. To give you a better idea of what's happening, I'll post the PHP code:

               

              <?php
              /*
              * Created on 19-mrt-10
              *
              * To change the template for this generated file go to
              * Window - Preferences - PHPeclipse - PHP - Code Templates
              */
                   include '../../application/general/php/general.php';
                  
                   // connect to the database
                   $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());

               

                  // select the database
                  mysql_select_db( DATABASE_NAME );
                 
                  // query the database to retrieve all customers.
                  $query = "SELECT * FROM stores";
                  $result = mysql_query($query);
                 
                  //start outputting the XML
                  $output = "<result>";
                  if($result) {
                      $output .= "<success>yes</success>";
                      $output .= "<stores>";
                 
                      // create a store tag for each retrieved store
                      while($customer = mysql_fetch_object($result)) {
                          $output .= "<store>";
                     
                          $output .= "<naam>$customer->naam</naam>";
                          $output .= "<adres>$customer->adres</adres>";
                          $output .= "<postc>$customer->postc</postc>";
                          $output .= "<wpl>$customer->wpl</wpl>";
                          $output .= "<land>$customer->land</land>";
                          $output .= "<telprive>$customer->telprive</telprive>";
                          $output .= "<telbureau>$customer->telbureau</telbureau>";
                     
                          $output .= "</store>";
                      }   
                     
                      $output .= "</stores>";
                  } else {
                      $output .= "<success>no</success>";
                      $output .= "<error>\n";
                      $output .= "Reason: " . mysql_error() . "\n";
                      $output .= "Query: " . $query ."\n";
                      $output .= "</error>";
                  }
                 
                  $output .= "</result>";
                 
                  print ($output);
                 
                  mysql_close();
              ?>

               

               

              When the error occurs, I get a <success>yes</success> and yet again the Fault error is thrown. Again, with fewer records, no problem.