Code Thread (Flash-XML-PHP-Mysql)

Well… this is probebly going to take a while to get started… but I’m going to attempt to build enough simpathy for a specific forum devoted to “back end”. Nope… no pictures of people’s buttocks will be allowed. I’m talking about PHP, ASP, Mysql, ColdFussion, XML, DHTML, craziness.

In these thread I’ll be posting some snippets of code that I’d found around the web. I hope other’s will take time to do the same.

This particular thread is devoted to Flash to XML to PHP to Mysql, and back again. So keep all your freaky ASP questions to yourself for now… one thing at a time.

I don’t have any code off the top of my head… I need to organize some thoughts… but for now, we’ll go through some basic info about it. You may have heard or seen the words XML, PHP, MySQL and wondered what they were, and what they are good for. “Why do I need XML or PHP?”

Well for starters they are two different things, with two different jobs… so my talking about them as if they are similar would be misleading.

PHP is a language like Flash’s action script. It is good at creating and writing code from a set of instructions.

XML is a “mark up” language like HTML, which is really good at BEING parsed for data. That is to say… small bits of code are all it takes to cycle through everything in an XML document and extract what we need at the time of the code’s execution.

MySQL is a type of database software that some servers run. Usually for an SQLDB you’ll end up having to spend a couple of bucks. It allows a number of users with differing access levels to either read or write data from a group of well organized tables of data.

So… the nature of “Flash to XML to PHP to Mysql and back again” is this.

Your SWF creates data from user imput. The SWF sends data to a PHP script located on the same server as the SWF, in the form of an XML document.

That PHP script organizes and adds to that data based upon the tags of the XML doc. It then sends that data to the SQLDB for storage.

Flash calls out to another PHP script requesting a load of variables.

The PHP script understands the request and sets about retreiving data from the SQLDB based upon that request’s instructions.

PHP “parses” the data into an XML formate and sends it on it’s way to Flash.

Flash accepts the XML document as an object which can be searched using all of the XML a/s in Flash 5.0.

Movie clips and text fields can then be dynamicaly created, to fill with data from the XML doc as the user requests it.