3 Replies Latest reply on Jan 12, 2007 5:27 AM by Hugo_Core

    Flex and Php

    xyco45 Level 1
      FLEX CODE

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="http.send()">
      <mx:Button x="197" y="198" label="Button" click = "testing()"/>
      <mx:Script>
      <![CDATA[
      public function testing():void
      {

      mx.controls.Alert.show("this is the output " + http.lastResult.happy);
      }
      ]]>
      </mx:Script>
      <mx:HTTPService id = "http" method="POST" url = "PHPDocument1.php" useProxy ="false">

      </mx:HTTPService>
      <mx:TextInput x="260" y="111" id="n"/>
      <mx:TextInput x="182" y="45" id="last"/>
      </mx:Application>


      PHP CODE

      <?php
      $happy = "<happy>cheesey</happy>";
      echo $happy;
      ?>




      The problem I having is for some reason.. it won't even load anything! it works with loading XML and TXT files but it doesn' t work with Php or my Python scripts.. basically its unable to communicate with server-side scripts. What could be the problem?
        • 1. Re: Flex and Php
          chris.huston.t10 Level 3
          Your testing function is not being called. You need to set the result event like this:
          <mx:HTTPService
          id = "http"
          method="POST"
          result="testing(event)"
          url = " http://localhost/PHPDocument1.php"
          useProxy ="false"/>

          You can then get the result in two differnt ways:
          public function testing(evt:ResultEvent):void
          {
          mx.controls.Alert.show("this is the output " + http.lastResult.happy);
          trace(evt.result.happy);
          }

          Using evt.result is often more flexible than http.lastResult for me since you are able to decouple the result from the call. It also is helpful for debugging if there is a problem.

          Vygo
          • 2. Re: Flex and Php
            Hugo_Core Level 1
            Very Nice!

            On the same subject i leave you with a dout:

            - I have a RIA similiar to xyco45 , but because im portuguese :P i use special characters like 'ç' or 'á'. And when i post data from flex with this caracters to the PHP Script, it changes to anothers like this '§'.

            I bet on the PHP Script..

            Tkz Core..
            • 3. Re: Flex and Php
              Hugo_Core Level 1
              Got it!

              Here the Solution for my Question if anyone need:

              PHP:
              <?php
              ...
              header('Content-Type: text/html; charset=UTF-8;');
              ...
              mail($mailto, $subject,
              $messageproper,
              "From: [FRANCHISING]\n" .
              "MIME-Version: 1.0\n" .
              "Content-Type: text/html; charset=UTF-8;");
              ...
              ?>

              We must specifty the charSet type.