Display html data from database as flash? - php

I want to display html(text) data into flash .Is there any way to do this dynamically? I am able to do this by creating an external xml file but how is it possible to do the same job without creating the external xml file using php and database?
thnks..

Flash is a client side script and to access Database you need to use server side scripting which is PHP. Follow these steps:
Use PHP to connect to DB
Obtain Data or Store Data using MVC or simple PHP file whichever you are comfotable with.
Obtain Data in XML format or Store it by parsing from a POST variable as you do in HTML forms.
Use flash to talk to PHP rather than direct Database.
If you are worried about direct access to PHP then find a way to encrypt your call to PHP so it only responds from flash and not from any other headers. Maybe someone else can put some more details in for you.
Also see http://www.kirupa.com/developer/actionscript/flash_php_mysql.htm

An alternative to having Flash contact the a php page to get the text is to have the server generate the flash dynamically (providing it is not too complex) using, for example, the Ming or SWF Libraries.

You also have the option to use some of Flash's more advanced built-in remoting tools. If you are running PHP on your back-end, for instance, you could set up AMFPHP or ZendAMF. What this does is open a binary socket connection between the server and your client, and if you set it up right then you can alias remote classes to local classes and vice versa. So for instance you could define a "UserModel" class in Flash and a UserModel class in PHP, and then tell Flash to treat them as aliases of each other.
What this basically lets you do is make remote server calls as though they were local method calls.
Every major Flash project I've been on has used this approach. It's much faster than XML, you don't need to worry about parsing XML or JSON, and you can make remote method calls nicely. This works best if coupled with some sort of MVCS framework like RobotLegs, because then you can abstract away the server calls entirely - but that may be more complex than what you need, depending on what you're doing.
But, the long and short of it is that Flash can't talk to a database directly.
ACTUALLY, one more thing comes to mind - Omar Gonzalez has been working on something called MongoAS3, which allows flash to connect directly to a MongoDB database instance. It would require that your database be a NOSQL MongoDB rather than a standard MySQL but it might be good for your needs: http://www.mongoas3.com/

Related

Asp + vXML dynamic data

I have been put in charge of building an IVR using vXML and asp.net. For some reason the voice server we are using requires ASP.net and cannot use PHP in conjunction with vXML so I am stuck learning ASP.net. The application is pretty simple in that it runs an ASP.net file with vXML and should pull data from a database based on user input.
Example:
User enters customer ID "23313"
It should then pull data from our SQL2012 DB that corresponds to that ID and read it back via prompts. Simple enough I figured.
A have a couple questions regarding possible solutions to this -
Is it possible for ASP/vXML to pull data from PHP dynamically (post or get statements), and use the data in the current vXML document? or will I have to bite the bullet and figure out a second page?
if using PHP is not ideal or possible, would it be better or possible to add a db connection into the asp/vXML document and run the IVR that way?
I am not very familiar with ASP.net, and am trying to find out the most efficient way to accomplish my goal without having to have an additional vXML page to run.
Any help appreciated.
EDIT
After further investigation and help from Jim I was able to get inline PHP working. The server I was using was set to go specifically to this asp.net and did not have PHP installed on the server itself. After installing PHP, changing where the server was looking for the file, I am able to run the latest PHP version in my app.
Deleted code sample as it was completely irrelevant
The ASP requirement seems odd, unless you are leveraging some type of library within the ASP.net environment. VoiceXML browsers, are just that, a browser. It should be able to process VXML from the standard sources. I suspect you are working within a framework that requires the serverside ASP.
If your browser is VoiceXML 2.1 compliant, you should have access to the Data element. This element allows you to make Get and Post requests to a server, get back XML and parse the data within Javascript. Note, the return data must be valid XML.
Any database connection would have to be on the ASP.net side of the solution. VoiceXML gets data by transitioning to a new page (goto or subdialog element) or the Data element above.

Getting data from MYSql into my iOS app with JSON

Ok I found a few questions on how to get data from a MYSql database into an iOS app, but I am just asking a few best practices here. I know these can all be separate questions, but I am hoping that they can be answered in a way that they relate to each other.
Am I correct to understand that to be able to get data into an iOS app - I need to first generate a JSON file, have that stored on a server and than have the app download this file??
If the previous answer is NO then does that mean, I can pull in data on the fly?
Lastly I have seen PHP examples to create JSON files, but iOS is in Objective-c. Does this mean I need to load a UIWebView to be able to load the PHP page that generates the file?
What I have:
I have a MYSql database - it is set up through PHPMyAdmin, so I am not familiar enough with the creation process of the database yet. I will look into that.
I can also export the JSON file from PHPMyAdmin, but that is no good to me in a iOS app.
I also have the parsing from a JSON file into an iOS app sorted, but I want to be able to do this on the fly instead of creating potentially hunderds of files.
I hope someone can help me here:-)
I am not necessarily asking for code, but would be mad to ignore it:-)
The problem is that there are not any iOS libraries for directly connecting to a MySQL server; and you really wouldn't want to do that, anyway. So, you need an intermediary server capable of sending data in a format your iOS application can understand. Note, this does not mean the data has to be JSON formatted. But it is very easy to use JSON as the format for your data. Most languages have native support for generating JSON from its native object format(s).
Once you have a server capable of sending data in your preferred format, you need to write some way for your iOS application to retrieve it. You do not have to use a UIWebView for this. As mentioned, the NSURLConnection framework is very easy to use to make such a request. However, there are a lot of other factors to consider when making network requests and others have already done most of the work for you. I like using the AFNetworking framework in conjunction with JSONKit. AFNetworking makes asynchronous calls to remote web services very easy, and JSONKit is nicer than NSJSONSerialization in my opinion.
What I do to retrieve data from MySQL to my iOS app is:
Create a PHP file on your server and prepare it for GET methods (you're going to send data from the iOS app)
Send a request from your iOS app to your php file, like: "www.yourdomain.com/data.php?name=..."
Process the information on your php file and echo the json output.
When connectionDidFinishLoading: convert the NSData to an Array using NSJSONSerialization.
Do whatever you like with the output information
That's just do way I do. I'm not familiar with other approaches.
PHP (and any other server side language) can take the data from the MySQL database and output it to any client as JSON, on the fly. No need to save the JSON to disk beforehand. Of course, from the client's point of view, there really is no fundamental difference (except the data will always be the latest representation of what's in the database).
You also don't have to use a UIWebView. There's a number of ways to make an HTTP request using Objective-C, but you'll likely want to look at something along the lines of NSURLConnection's sendSynchronousRequest:returningResponse:error: method (I prefer using synch methods inside an async block, but that's not the only way). You can find many tutorials on how to do similar things, as well as higher level libraries to simplify the process.

Android remote MySQL operations using a web service with php

I read some nice articles about how to connect to a remote MySQL database via Android.
Found some really interesting links here and here.
So the common way for getting data seems to be using some kind of webservice (interface, in this case a php script) which queries the db and renders the result in JSON (or XML) format. Then its possible to parse this output with the android JSON_Object implementation. So far so good.
Receiving data from the database and showing it up in a android listview was done in about minutes.
But what is the best practice for writing (inserting) data into tables?
Should a webservice be used here too? (or rather direct mysql conn)
What is the best method to push data to a webservice? (for ex. to insert a new entity in a database) and which format should be used?
In this case I do not use any html forms or anything to post the parameters. So how to post these parameters to the php script? (from within the android app!)
Of course this operation should be secure as well. Implementing a data manipulation machanism is bit more risky (in order to keep the db persistant)
I think, that many apps use some kind of DB, to synchronize data (ex: highscores).
So there should be a best practise for that.
I would recommend keeping anything database-specific hidden behind a web service.
If you build a dependency on MySQL into your application and later find that you need to change databases, the entire installed base has to be cut over. Think about the logistics of accomplishing that for a few minutes and you'll start to realize it's a nightmare.
Premiumsoft's Navicat for MySQL comes with a HTTP tunnel (PHP script) you might be able to use. It basically provides a method for doing anything to a MySQL database over HTTP.
I'd just make sure there are no licensing issues if you plan to distribute your app.

Connecting Php with javascript

I am trying to make a plugin that people can place on their site to generate a form. I dont want to use an iframe to display the form but use javascript to generate it.
The problem is how do i connect the javascript and php together. My site is programmed in PHP.
Your getting a liite mixed up, I think.
PHP runs on your server. This is the place where you fetch data from the database and create some form of html-response.
Javascript runs in the browser. It can't directly talk to your database.
iframe is a special html-element: Therfore it is passive and can't do anything like creating a form.
You have two ways:
Create a PHP script which handles everything through plain HTTP-Requests. This is the "old school" way and requires a lot of page-reloading.
Write most of the logic in javascript and let it communicate to PHP/your database through AJAX. In this case. Have a look at jQuery which makes AJAX-requests (and a lot of other things) very easy.
One issue you will be faced with is 'Cross site Scripting' with Javascript / AJAX.
You can read up on it a bit here:
http://snook.ca/archives/javascript/cross_domain_aj
Also, thinking your process through, you will need sufficient javascript code to create a 'widget' on any place, and have a way to communicate BACK to your server (keep in mind PHP only runs local on your machine, so it cannot be used remotely in your javascript).
You will probably need to build a JSON API (google / stack search this if needed).
And enable communication from your JAVASCRIPT to the API (don't think of it as to PHP, even tho php will be your API server side language).
Here is an example of a PHP JSON API (on youtube too):
http://www.youtube.com/watch?v=F5pXxS0y4bg
If you put PHP into JavaScript and someone implements this, PHP will compile on their server. So you just can't. You just need to put the form in your plugin.

control loaded flash file using php or js

is there a way to write a program in php or javascript that can load a flash file and interact with it? (click on buttons and such)
JavaScript
Here's a good example of Flash/JavaScript interaction using the YouTube Chromeless Player.
PHP
While you could use a query string to retrieve data from a php file or have a PHP file pre-populate FlashVars you can also use PHP with amfPHP for more robust database interaction.
ActionScript
Maybe these links will help:
Basics of using the External Interface or External Interface
There are many ways to work server/client/flash interactions into your presentations, but for what purpose would probably be the question you should be asking. I've developed a chat client that interfaces with a jabber server through java and in turn with a Sony MMPORG game. There are many interactions between the client(browser), the server(s) and of course flash. Considering it was a flash application the interaction needed to be there in order to make the entire experience a lot more intuitive and useful for the end-user.
You can see the screenshots of this client here:
EQ2 Web-Chat Client - Javascript/Actionscript/DHTML by DrLouie - Jabber/Java Communication by PC(Pierce Courtney)
Unfortunately you cannot access the live client unless you have an active Sony Station account for EverQuest 2. Keep in mind this was developed way back in 2004, so if it was possible then, it's a lot more possible today. It's a fun way to develop flash interfaces! Even more fun is finding the possibilities of flash/javascript/server interactivity, which tends to be somewhat limitless to an extent...
Look at the ExternalInterface if you are using Flex.
http://blog.flexexamples.com/category/externalinterface/
Yes, you can load a flash file (.swf) into html document and make it interact with php, but! flash is the responsible of the interaction, sending data to php, so the swf file should do it, using the loadvariables() function.
good luck!

Categories