A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: mySQL vs. XML

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    13
    What would be a better choice?

    Using mySQL and PHP, or XML?? And why

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhm...

    If your trying to compare Databases... XML would be slightly above the level of... a flat text file of name/value pairs...

    I would recommend looking into what XML is before you get into using it or not using it...

    In most cases I store everything in a MySQL database, pull it from the DB using PHP, and send it to a Flash front end using XML. No joke. Having that many different stages seems to work best... that way I can change my interface however I want, and not have to worry about the data transfer.

    Now... if you're talking like XML is a scripting language like PHP... then you've really got some research to do...

  3. #3
    very true, i find that well organized mysql tables allow for easy transfers. i use the same method:

    mysql for data
    php to create xml (dynamically)
    xml to flash

    im a beginner but recently just created a movie which does this. pretty simple and a lot of fun
    good luck

  4. #4
    Junior Member
    Join Date
    Jul 2002
    Posts
    13
    How would I go about dynamicaly creating XML with PHP?

  5. #5
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhm...

    I'm assuming you can make HTML with PHP.. XML is the same. Tags, attributes, text... Look into XML and you'll see it's easy to do basic stuff - then if you wanted to get into the more complex things, PHP has interfaces to generate XML.

  6. #6
    you would loop your script to draw data from the mysql table and print out the tags

  7. #7
    Junior Member
    Join Date
    Jul 2002
    Posts
    13
    I'm quite addept at PHP, but I've never examined the XML usage of it, I'll take a look.

    Does the PHP have to actually create am XML file? Cause that would mean that if it were on a server which was on 'safe mode' the code wouldn't work.

  8. #8
    you could try something like this

    Code:
    //fetch the data from the table
    $result = mysql_query("SELECT * FROM $table", $link);
    for ($i=0;$i<mysql_num_rows($result);$i++)
    {
    $data[] = mysql_fetch_array($result,MYSQL_ASSOC);
    }
    
    /*
    data now contains an associative array
    make it into XML
    */
    
    $xml_data = '<dbData>';
    foreach($data as $key=>$val)
    {
    //$xml_data .= "<id value=pic>";
    $xml_data .= "<pic>";
    foreach ($val as $nKey=>$nVal)
    {
    $xml_data .= "<$nKey>$nVal</$nKey>";
    }
    $xml_data .= "</pic>";
    }
    $xml_data .= '</dbData>';
    //echo $xml_data;
    
    //write to xml file
    $fp = fopen($xml_name,'w') or die("Couldnt open $xml_name");
    fwrite($fp, $xml_data);
    fclose($fp);
    echo "success!";
    you get it, just a standard forloop from the array

  9. #9
    Junior Member
    Join Date
    Jul 2002
    Posts
    13
    tnx, but it won't work on a safe mode server.

  10. #10
    Member
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    38
    I´m exploring the possibiltys of mySQL, php en XML connections and data transfer, but I´m am still not really clear on what this can do to a Flash movie, does anyone have any exapmles of such sites / Swf´s that use this connection in an effective way ???

  11. #11
    ive been working on one lately, its going to be a picture gallery.

    i created a php page where i can submit a pic, title, and description. the script automatically inserts thisinformation into a mysql database. after this is done, it creates an xml file with the data.

    the flash gallery then takes the name, description, and filename from the xml and loads it directly inside the movie. everything is dynamic, meaning i will never have to change the .fla if i want to add something to my gallery. all i have to dois submit it with the php page

    hope that helps

  12. #12
    oh yeah when im done ill release it in the forums so everyone can check it out.

  13. #13
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhh...

    I know that::

    http://www.perryhomesutah.com

    and

    http://www.utahvalley4x4.com

    Use Flash on the front-end, MySQL on the back-end, and PHP to format XML that is given to the Flash...

    It's very simple what this can do WITH a Flash movie... Flash displays data, MySQL holds it, PHP talks to MySQL and gives the data to Flash in an XML format...

  14. #14
    Senior Member enstent's Avatar
    Join Date
    Oct 2001
    Location
    Toronto ON
    Posts
    238
    Does Mysql work with Flash?

  15. #15
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhm...

    WARNING - THIS IS MEANT TO BE FUNNY
    Do you know what MySQL is??
    Do you know what Flash is??
    WARNING - THAT WAS MEANT TO BE FUNNY

    So... the short answer - yes.

    Good enough?

    If you're asking - Can Flash execute SQL queries directly - No.

    If you're asking - Can some middleware (PHP, ASP, JSP) send information from a MySQL database to Flash - Yes.

  16. #16

    Post Why use XML? - I'm a beginner

    I understand using PHP (or ASP) to populate a database and then pulling that data from the database to display in Flash (through PHP, ASP, etc.), but what value does XML add to the party?

  17. #17
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhm...

    If you've ever had to serialize or deserialize data, to be exchanged between anything, you'd see the 'coolness' of XML.

    Aside from the fact that all - and I mean ALL of the major players try to put XML in their products somehow... and aside from the fact that XML is meant to not be tied to a 'standards definition'... it really isn't that much.

    BUT since it is everywhere, and everything can 'parse' XML, and since it is not tied to a strict standard (is you can make up your own tags if you want) - it rocks.

    For instance...

    Flash can not 'understand' PHP, and PHP can not 'understand' Flash - but both of them 'understand' XML... so that's one way they can communicate.

  18. #18
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    XML is to Data what RTF is to documents!

    When all else fails you know that XML (or RTF in the case of documents) will work.

    Thanks

    Luke


  19. #19
    Senior Member enstent's Avatar
    Join Date
    Oct 2001
    Location
    Toronto ON
    Posts
    238
    How well does PHP undertstand XML?

  20. #20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center