2 Replies Latest reply on Aug 10, 2009 5:59 AM by sugu0925

    Help: Integrating with PHP?



      I am very new with flex, php and browser/server software development. I am trying to send a simple request to server using HTTPService and run a PHP script to get a response. I started with one of available tutorial examples. I am including code snippets below.


      <testphp1.php> file contents:

      $msg = "Hello world! It's me, PHP!";
      echo $msg


      testphp.mxml file contents:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
      <mx:HTTPService id="phpService"
           resultFormat="object" result="showResult()"/>
           import mx.controls.Alert;
           private function showResult():void {
           Alert.show(phpService.lastResult as String,'Message from PHP');
      <mx:Button label="Call PHP" click="phpService.send()"/>



      When I type the URL on browser, it shows the expected string. When I run it from Flex builder, I get "Page Cannot be found" message on the browser window that pops up. And on the flex development side, a new window pops up saying "Launch failed ... Failed to connect; session timed out..."


      if I put the same data on an XML file and change the URL to point to the XML file, it works just fine.


      I am guessing, my issues have to do with some configuration parameter on flex, PHP or IIS. I have no clue as to how I can debug this. Could you please help?



        • 1. Re: Help: Integrating with PHP?



             You can add the  below in the HTTPService tag and can ctach the error in the fault function phpService_fault()



                    <mx:HTTPService id="phpService"   url="http://localhost/testphp1-debug/testphp1.php"    resultFormat="object"

                     result="showResult()"   fault="phpService_fault(event);"     result="phpService_result(event)" />



          In the Script


             private function phpService_fault(evt:FaultEvent):void
                 Alert.show("The error"+evt.fault.message);


               private function phpService_result(evt:ResultEvent):void





          I hope the above helps you in tracking the error





          1 person found this helpful
          • 2. Re: Help: Integrating with PHP?
            sugu0925 Level 1

            Thanks! It turned to be some mismatch of expected flash player vs. what was installed. Now I am on to exploring flex! Thanks again!