0

How do I execute php code which is in another file from my flex application?

The php code I want to execute (nice and simple)

 <?php
     echo "My first PHP script!";
 ?>

So I want the above to execute. So far I have this in my flex application:

 <mx:HTTPService id="userRequest" url="C:\Users\blah\blah\blah\src\ItemTableService.php" useProxy="false" method="POST">

    </mx:HTTPService>
</fx:Declarations>
<mx:Button label="Submit" click="userRequest"/>

So I'm running it locally at the moment. I think there needs to be something on "click-"userRequest.(somethinghere)"/> but not sure what it needs to be.

0

1 Answer 1

1

I use the UrlLoader class

var url:String="example";
        var urlRequest:URLRequest=new URLRequest(url);
        urlRequest.method=URLRequestMethod.POST;
    //use variables only if yu need them    
var variables : URLVariables = new URLVariables();
        variables.something=ex;
        urlRequest.data=variables;
        var urlLoader:URLLoader=new URLLoader();
        urlLoader.addEventListener(Event.COMPLETE, onComplete);
        urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
        urlLoader.addEventListener(IOErrorEvent.IO_ERROR,onError);
        urlLoader.load(urlRequest);

Try first your php n your browser see if you can get the correct url, it should be something with localhost or 127.0.0.1 like

http://localhost/myscript.php

Edit as Josh suggested in the comments you MUST have a web server with PHP support installed and setup.

Sign up to request clarification or add additional context in comments.

1 Comment

Worth noting that PHP requires server-software to run, too. Just having the file on your system is not enough, you'll need to be running Apache or similar (through XAAMP/WAMP/MAMP or similar, generally) to have it run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.