dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: [xml+php+as] cant retrieve row $ID in Flash..

  1. #1
    Member
    Join Date
    Mar 2005
    Posts
    96

    [xml+php+as] cant retrieve row $ID in Flash..

    Hi.. this is my PHP code

    <?php
    header("Content-type: text/xml");

    $host = "localhost";
    $user = "root";
    $pass = "";
    $database = "samdb";

    $linkID = mysql_connect($host,$user,$pass) or die ("Could not connect to host.");
    mysql_select_db($database,$linkID) or die ("Could not find database.");

    $query = "SELECT * from songlist WHERE genre='Emo' ORDER BY ID ASC limit 25";
    $resultID = mysql_query($query,$linkID) or die ("Data not found");

    $xml_output = "<?xml version =\"1.0\"?>\n";
    $xml_output = "<songlist>\n";
    $count = mysql_num_rows($resultID);
    for ($x = 0; $x < $count; $x++){
    $row = mysql_fetch_assoc($resultID);
    $xml_output .= "\t<songlist>\n";
    $xml_output .= "\t\t<artist>" . $row['artist'] . "</artist>\n";
    $xml_output .= "\t\t<id>" . $row['ID'] . "</id>\n";
    $xml_output .= "\t\t<title>" . $row['title'] . "</title>\n";
    $xml_output .= "\t</songlist>\n";
    }
    $xml_output.= "</songlist>";

    echo $xml_output;
    ?>
    And if you go to the URL : http://snazzyfm.no-ip.info/shout/songlist_retrieve.php

    The results is :

    onglist>
    +
    <songlist>
    <artist>Starting Line</artist>
    <id>416</id>
    <title>The Best Of Me (Acoustic)</title>
    </songlist>
    -
    <songlist>
    <artist>Brand New</artist>
    <id>509</id>
    <title>Am I Wrong</title>
    </songlist>
    -
    <songlist>
    <artist>Brand New</artist>
    <id>510</id>
    <title>Moshi Moshi</title>
    </songlist>
    -
    <songlist>
    <artist>Further Seems Forever</artist>
    <id>566</id>
    <title>Monechetti</title>
    </songlist>
    And in Flash, here's what I did to display all the Artist and Title in sequence.

    // retrieve songlist

    function loadXML2(loaded) {
    if (loaded) {
    songlist.htmlText = "";
    var myXML = xmlData.firstChild.childNodes;
    _global.artistA = [];
    _global.titleA = [];
    for (i=0; i<myXML.length; i++) {
    _global.artistA[i] = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
    _global.titleA[i] = this.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild.nod eValue;
    songlist.htmlText += "<b>"+artistA[i]+"</b> " + titleA[i]+"<br>";
    }
    }
    }

    // load songlist
    function reloadXML2() {
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML2;
    xmlData.load("http://snazzyfm.no-ip.info/shout/songlist_retrieve.php");
    }

    loop songlist
    reloadXML2();
    setInterval( reloadXML2, 1000 );
    and all is working fine but right now i'd also like to display results of ID in Flash, but this is what i did and it didnt seem to work

    _global.IDA = []; // added this

    _global.IDA[i] = this.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild.nod eValue;

    // and this
    songlist.htmlText += "<b>"+artistA[i]+"</b> " + titleA[i]+IDA[i]+"<br>";
    Or is there something i should know about ID (which is the Primary Key) that cannot be displayed in Flash this way? Please advise someone, I'm stumped!

  2. #2
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Removed. Originator has asked in another forum.
    Last edited by Chris_Seahorn; 05-08-2006 at 06:48 PM.

  3. #3
    Member
    Join Date
    Mar 2005
    Posts
    96
    Hey Chris!

    Wow. It worked. Thanks a lot!! But I have some stuffs to confirm, why do the global var declaration between artist & title and ID differ

    _global.titleA = [];
    _global.myid = [];

    why doesn't ID require A at the end?

    and why is ID written this way "this.firstChild.childNodes[i].firstChild.nextSibling.firstChild.nodeValue;"

    im sorry im a newbie at this. and would like to understand more..

    thanks again Chris!

  4. #4
    Member
    Join Date
    Mar 2005
    Posts
    96
    and here's what i want to do next with _global.myid = [], since each song has a unique ID, i want to assign a request button where when users click the button it will retrieve the unique ID for that song to be sent to PHP, im not sure if this is how it's gonna be done.. but here's what i have in mind..


    myLoadVars.SongID = _global.myid;
    myLoadVars.sendAndLoad("http://snazzyfm.no-ip.info/flash_request.php", "POST");

    where the PHP will have some fucntion that would take the ID taken from Flash and integrate it with other functions for request to work
    Is it done like that?

  5. #5
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Removed. Originator has asked in another forum.
    Last edited by Chris_Seahorn; 05-08-2006 at 06:48 PM.

  6. #6
    Member
    Join Date
    Mar 2005
    Posts
    96
    Chris, is there anyway i could prevent the browser from popping up when users click the request button as my application is supposed to be standalone and it'd kinda kill the function if suddenly a browser pops up. hehehe.

    im really new at this, and im just combining stuffs i found. i know there are easier ways of doing it.

  7. #7
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Thats what I was explaining....lol. Give me a bit....I'll make something here to test with and repost the code. Mind you it will be setup completely different. On the upside, you will be able to pack in a bunch of actions in a section of the way I do it that will make more sense and allow you more options.

    I'm having a "finished my deck" party so bear with me...the wife is fuming everytime I sneak way to code I'll post back.

  8. #8
    Member
    Join Date
    Mar 2005
    Posts
    96
    Hey Chris, glad to have someone helping me out coz Im super stumped on this. I'm actually trying to integrate this with a request/dedication system belonging to SAM Broadcasting tool. so the idea now is to retrieve the uniqe ID of each song to be sent to the PHP to do its other magic of sending the song to the broadcasting tool and database.

    here's a ZIP file containing what i'm trying to do and what it needed to communicate with once the ID reaches the PHP..

    http://snazzyfm.no-ip.info/SonglistRequest.zip

  9. #9
    Member
    Join Date
    Mar 2005
    Posts
    96
    I just figured out something, if i were to have the songID then request can be made sttraight away with this URL

    http://snazzyfm.no-ip.info/snazzyfm/req.php?songid=2427

    if let say the songID is 2427, with that URL request are made straight away. the problem now can i attach to a button?

    <a href='http://snazzyfm.no-ip.info/snazzyfm/req.php?songid="+myid[i]+"

  10. #10
    Member
    Join Date
    Mar 2005
    Posts
    96
    check it out, i now have a working songlist that when i click the request button it would echo the songID in my PHP

    http://snazzyfm.no-ip.info/SonglistRequest3.exe

    but how do i do the "silently hit PHP wifout oepning browser" lol

  11. #11
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Ok man....party is over...thanks for being patient
    Last edited by Chris_Seahorn; 05-08-2006 at 12:30 AM.

  12. #12
    Member
    Join Date
    Mar 2005
    Posts
    96
    Hey Chris, awesome file you've got there but right now im too whacked to apply that to what i've done. but anyhoo, im not sure if you've seen my latest dev file and i think you should coz its nearly finished but im lost. i cant seem to pass the vars from Flash to PHP... ive tried from a HTML form, is vars are pssed to that PHP..bam the request & dedication would work for my application.. but right now it isnt Can you please take a look at my SendAndLoad.zip, here;'s the link if youve lost it

    http://snazzyfm.no-ip.info/SendAndLoad.zip

  13. #13
    Member
    Join Date
    Mar 2005
    Posts
    96

    ..

    I attached the file if my server is too slow for you to download from..hee..
    Attached Files Attached Files

  14. #14
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Dude.....it's a Flash 8 fla. I'm on MX2004.

  15. #15
    Member
    Join Date
    Mar 2005
    Posts
    96
    Oh crap! Hold on I'll change it to MX..

  16. #16
    Member
    Join Date
    Mar 2005
    Posts
    96

    ..

    Here's the new zip bro, with the MX file!
    Attached Files Attached Files

  17. #17
    Member
    Join Date
    Mar 2005
    Posts
    96

    ..

    Dammit, I missed out a variable in the container to be sent to PHP.. i attached the updated ZIP with RequestDedication_Update.fla in it..

    Im sorry Chris for troubling..
    Attached Files Attached Files

  18. #18
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Removed. Originator has asked in another forum.
    Last edited by Chris_Seahorn; 05-08-2006 at 06:48 PM.

  19. #19
    Member
    Join Date
    Mar 2005
    Posts
    96
    Ah, thing is i have just too many people helping me out and im stumped with which to follow. Anyway, Chris, the problem I have now is with the dangg dedication part, (the green headphone with a white dialog box icon), if you click that, it will go to a frame where your name and message is required. once Submit is pressed, its suppose to SendAndLoad variables into flash_post.php, but somehow it isnt.. im not sure whether its my Flash, or his PHP is faulty.. Because from a HTML form, his PHP seem to be working! hehe

  20. #20
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I think were good. I've been testing my copy here and it sends it to my php and Bitterpill.txt correctly reflects it. All in the background.

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