3 Replies Latest reply on Sep 19, 2011 1:00 PM by mckeyes2

    Inserting data into MySql

    mckeyes2

      Hi all, I'm using FlashBuilder 4.5 to develop a web app. Followed all the tutorials and samples I could find for this. Basically a user goes through a few screens and selects options from drop downs and enters a few numbers in. At the end they are presented with their results. I would like to take all the values they entered and insert them into a database using PHP.

       

      I used the Connect to PHP option and everything configured correctly. Using the test feature, I can get the inserts to work. When running the app in debug mode it steps through all the lines and finishes without error but nothing gets inserted into the database. I followed the samples on Adobe's site and everything appears to be similar but I cannot figure out why it's not working.

       

      Application section:

      xmlns:riskresultsservice="services.riskresultsservice.*"

       

      Service call: createRiskResultsResult.token = riskResultsService.createRiskResults(riskResults);

       

      <fx:Declaration section I have

      <valueObjects:RiskResults id="riskResults" />

      <s:CallResponder id="createRiskResultsResult"/>

      <riskresultsservice:RiskResultsService id="riskResultsService"

         fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"

         showBusyCursor="true"/>

       

      I then have a function that sets all the values for riskResults

      example:

      riskResults.age = risk_age;

      riskResults.height = risk_height;

       

      I set a watch for riskResults and I can see the values being set.

       

      Please help

      Thanks

        • 1. Re: Inserting data into MySql
          mckeyes2 Level 1

          I found where the hangup is but have no idea how to go about correcting. Following through in debug mode, I get to the AbstractServices.as file to the initialize function on line 375.

           

          public function initialize():void

          {

               if (!_initialized && _managers != null)

               {

                    for (var i:int = 0; i < _managers.length; i++)

                    {

                         var mgr:Object = _managers[i];

                         if (mgr.hasOwnProperty("initialize"))

                              mgr.initialize();

                    }

                    _initialized = true;

               }

          }

           

          it get's hung up on the mgr.initialize() statement. I get a "Source not found." with a button to Edit Source Lookup Path...

          I have no idea where to look for the source path. Is this a problem with the Flex SDK (4.5.1)?

          • 2. Re: Inserting data into MySql
            daslicht Level 2

            When calling: riskResultsService.createRiskResults(riskResults) Do you get a Error displayed ?

            Where/How are you handling the result for 'riskResultsService'?

             

            After setting :

            riskResults.age = risk_age;

            riskResults.height = risk_height;

             

            you have to call the service to write the actual changes:

            createRiskResultsResult.token = riskResultsService.createRiskResults(riskResult

             

            If you would post a bit more complete code we could maybe better help you

            • 3. Re: Inserting data into MySql
              mckeyes2 Level 1

              Thank you for the response. I hope I have enough info here. Most of the code here is auto generated within Flash Builder. All I really did was add the values into the insertItem valueObject and call the service handler. I don't need a vaue returned back to the application since all this is doing is recording values into a MySQL db. If I run this normally, it will run fine but nothing gets sent to the db. If i go through the debugger, it steps into the core files and fails while trying to initialize the service. Every exmple I find online has this implemented slightly differently so I'm not quite sure what's going on.

               

              <s:Application ...

                        xmlns:riskresultservice="services.riskresultsservice.*"

                        ...>

               

              <fx:Script>

                   ...

                   import services.riskresultsservice.RiskResultsService;

                   import valueObjects.RiskResults;

                   ...

               

                   private function createInsertArrayItems():void

                   {

                        insertItem.age = riskAge;

                        insertItem.actvity = activity;

                        insertItem.height = riskHeight;

                        ...

                   }

               

                   protected function btnNext_clickHandler(event:MouseEvent):void

                   {

                        // some of code

                        ...

                        createInsertArrayItems();

                        createRiskResults(insertItem);

               

                        ...

                        // some more code

                   }

               

                   protected function createRiskResults(item:RiskResults):void

                   {

                        createRiskResultsResult.token = riskResultsService.createRiskResults(item);

                   }

                   ...

              </fx:Script>

               

              <fx:Declarations>

                   <valueObjects:RiskResults id="insertItem" />

                   <s:CallResponder id="createRiskResultsResult" />

                   <riskresultsservice:RiskResultsService id="riskResultsService"

                        fault="Alert.show(event.fault.faultString + '/n' + event.fault.faultDefault)"

                        showBusyCursor="true" />

              </fx:Declarations>

               

              <s:BorderContainer>

                   ...

              </s:BorderContainer>

              ...

              </s:Application>