Flash lite 1.1 Actionscript and PHP - php

i need help on getting data from my database using php on actionscript?
any advice on how i can use loadVariables() or getURL()
i know PHP but im new with actionscript.

Here's the process:
Use loadVariables to call the PHP script:
loadVariables("params.php", target_mc);
URL encode the output from the database:
echo urlencode($resultset)

Related

iOS Swift / HTML-Code and PHP-Code in 'Strings'

I tried the following coding for a 'UIWebView:
let kapitel3 = "<html><head><title>Chapter 1</title></head><body><h1>This is a title!</h1></body></html>"
This HTML code works fine and "UIWebView" shows this code. But if I try to insert a PHP code within the HTML code like this:
let kapitel3 = "<html><head><title>Chapter 1</title></head><body><h1>This is a title!</h1><?php print \"Hello world!\";?></body></html>"
Then the PHP code won't be showed. Why doesn't 'UIWebView' translate this PHP code <?php print \"Hello world!\";?>?
Is it not possible to integrate PHP code in a String like above?
Thanks for any hints!
UIWebView is only a simple web-browser...
You can't use php like that if you don't have a local webserver with a php interpreter installed!
You could load a php page from a remote url but your phone must have an active internet connection...
Possible local solution:
You can't use php locally, but in a UIWebView you can still use javascript!
I don't know what you are trying to do...but if you need your app to work offline (with local files) using php is the wrong approach.

Call php file from metro application

I am currently in the process of creating a windows 8 application using C# and I need to access a php file from a website which has a function loginUser($userParam, $passParam) that handles user login into a database. Any hints on how this can be done? Should I use HttpRequest or is there another method?
You need to pass $userParam and $passParam via GET or POST query and call this function in your PHP script, like
echo loginUser($_REQUEST['userParam'], $_REQUEST['passParam']);
You can make GET or POST request with WebRequest, for example:
http://msdn.microsoft.com/en-us/library/0aa3d588%28v=vs.110%29.aspx

angular js with php integration

I used the code from http://angularjs.org/ (Wire up a Backend)
Here in project.js
angular.module('project', ['firebase']).
value('fbURL', 'https://angularjs-projects.firebaseio.com/').
factory('Projects', function(angularFireCollection, fbURL) {
return angularFireCollection(fbURL);
}).
config(function($routeProvider) {
I used this code in my web page. Instead of https://angularjs-projects.firebaseio.com/ url i want to use my url i.e http://test.com/test.php. But it didn't work.
Also i want to know in my php file in which format the out put should be?
Do you need to echo the content in php file or use the return command? Please give suggestion. I have searched a lot. I couldn't find the solution.
I think in firebase url https://angularjs-projects.firebaseio.com/ they are returning the response from their back-end service. That is why it didn't worked for you even if you changed the URL.
And answer to your second question;
If you make a call to your back-end service its better to have a json response style from your PHP and you don't have to use any return command for that. Instead you should echo your contents.
For example in your PHP file if you are getting the results as an array you can give back the response to the angular application as;
echo json_encode($result_array);
Hope it helps.
I think you should separate backend and frontend and treat them as two separated application. Both apps should communicate with each other by sending ajax request (front) and respone data in json format (backend). In my opinion it's the best way to handle this.

How to use decodeURIComponent in JS in Facebook?

I am trying to use decodeURIComponent in a JS function inside Facebook instead of using urldecode in PHP. But I keep getting the following error :
Error: a194182563946198_decodeURIComponent is not defined
Can anyone kindly help ?
Thanks.
-
Ahsan
On a second thought, I am using a PHP intermediate file that does the work on ajax call. :)
-
ahsan

How to connect these 3 programming languages?

How to pass information in this flow:
Flash(AS3) -> PHP, using XML -> Database(mysql)
Can anyone write a simple code for that?
Thanks.
http://www.kirupa.com/developer/actionscript/flashphpxml_integration.htm
This will tell you most of what you need to know to get started.
If you're not already tied to using XML, you might want to look into using AMF. There's a number of OSS implementations of AMF for PHP, from the obviously named amfphp to an implementation in the Zend Framework. Hopefully somebody with experience here will come along and provide a better answer.
What about WebService SOAP/WSDL?
So you can provide web service on php and send information from Flex/AS3/Flash by calling some webservice method and then store it into mysql db.
Flex has class WebService, so on client side to call server method is as easy as:
var webService:WebService = new WebService();
webService.wsdl = "http://yoursite.com/webservice.wsdl";
webService.loadWSDL();
webService.this_is_method_from_php_server(your_object_serialized_as_xml);
On PHP side I'm sure there are dozen libraries to provide SOAP/WSDL.
I would recommend using amfPHP to get information from a MySQL database passed to Flash through php. It is simpler, faster and easier to use than using php to output the database result in xml. Basically what you do with amfPHP is that you can call php functions directly from flash using the LocalConnection class.
I'll simplify some code to illustrate how it works:
//PHP code
//Here's you main php class which all the sql commands will be called
class Main{
public function saveUser($username, $password){
//I'll send in the username and password to insert it into the users column
$this->db->query("INSERT INTO users VALUES ($username, $password)");
//I'm using the MDB2 library for sql queries,
//you write less code when doing queries.
}
}
//Actionscript 3 code
//To pass parameters to my php function I have to make an array.
var amfParameters:Array = [];
amfParameters['username'] = "richard";
amfParameters['password'] = "123123";
//Then create a localconnection which will connect to amfphp.
var localConnection:LocalConnection = new LocalConnection();
localConnection.connect(gatewayURL); //gatewayURL is the url to the gateway amfphp file
localConnection.call("testproject.Main.saveUser", loaderResponder, amfParameters);
//testproject.Main.saveUser is the path for our Main.php file and saveUser is the function
//loaderResponder is a Responder class which handles the callback from amfphp.
So basically you will call the php function in flash, and you can also return data to flash aswell.
This is just to illustrate a little bit of how amfphp works. It's not meant to be a complete code sample. Just to give a brief idea.
Think about it and if you think it looks interesting go and download amfphp and try it out! You won't be dissappointed.

Categories