dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: mySQL / PHP (XML) / Flash

  1. #1
    Senior Member
    Join Date
    Jan 2006
    Posts
    183

    mySQL / PHP (XML) / Flash

    Hi,

    I have found a tutorial on mySQL/PHP/Flash at http://library.creativecow.net/artic.../php_mysql.php which takes the infos from a database, create an XML file with PHP to then feed a swf. It's brillant but not working how I want!

    I usually use XML with different variables in one node such as:

    Code:
    <?xml version="1.0"?>
    <items>
    <item> ID= "text" Text= "Hello World." </item>
    </items>
    For this project, I use the following PHP code:

    Code:
    <?PHP
    
    $link = mysql_connect("localhost","myDatabase","password");
    mysql_select_db("myDatabase");
    
    $query = 'SELECT * FROM about';
    $results = mysql_query($query);
    
    echo '<?xml version="1.0"?>' . "\n";
    echo '<items>' . "\n";
    
    while($line = mysql_fetch_assoc($results)) {
    	echo '<item> ID= "' . $line['id'] . '" Text= "' . $line['text'] . '" </item>' . "\n";
    }
    echo '</items>' . "\n";
    
    mysql_close($link);
    
    ?>
    And for the Flash code I use:

    Code:
    XML.prototype.ignoreWhite = true;
    var myXML:XML = new XML();
    myXML.load("about.php");
    
    myXML.onLoad = function(success) {
    	if (success) {
    		menuArray = new Array();
    		menuArray = this.firstChild.childNodes;
    		_global.ID = new Array();
    		_global.Text = new Array();
    		var i = 0;
    		while (i<menuArray.length) {
    			_global.ID.push(this.firstChild.childNodes[i].attributes.ID);
    			_global.Text.push(this.firstChild.childNodes[i].attributes.Text);
    			i = i+1;
    		}
    		trace(_global.ID[0]);
    		trace(_global.Text[0]);
    	}
    };
    The trace codes are to test that Flash connects and reads the php file. It does but it doesn't identify the information on the XML/PHP line, trace returns undefined instead of "text" and Hello World".

    Could anyone help me please?

    Thanks,

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    make changes to the php so it outputs -

    <items>
    <item ID= "text" Text= "Hello World.">
    </items>

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