dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Getting data TO and FROM flash php at the same time

  1. #1
    Senior Member
    Join Date
    Jul 2002
    Location
    New Mexico
    Posts
    101

    Getting data TO and FROM flash php at the same time

    I have xml data produced by a php page and I am trying to get information TO the php page for it to go to the database and retrieve the data and put it in xml format for flash. the problem I am having is getting the user data TO the php page...here is what I am trying to get to work:

    Code:
    serverdate = new Array();
    servercurrentQuestion = new Array();
    serveryouranswer = new Array();
    var my_xml1 = new XML();
    my_xml1.ignoreWhite = true;
    my_xml1.onLoad = function(success) {
    	if (success) {
    		
    	var myitems = my_xml1.firstChild.childNodes;
    	for (var i = 0; i<myitems.length; i++) {
    			serverdate[i] = (myitems[i].firstChild.firstChild);	//date
    			servercurrentQuestion[i] = (myitems[i].firstChild.nextSibling.firstChild);
    			serveryouranswer[i] = (myitems[i].firstChild.nextSibling.nextSibling.firstChild);
    			M1testDate = serverdate[i];
    			M1lastQuestion = servercurrentQuestion[i];
    		}
    			
    	}
    };
    username = "someusername";
    email = "someemail";
    testformat = "MATH";
    testnumber = "1";
    my_xml1.load("http://www.mydomain.com/flashdatatest.php?name="+username+"&email="+email+"&testtype="+testformat+"&testnumber="+testnumber);

    Here is my php code:
    Code:
    mysql_select_db($database_MyConnect, $MyConnect);
    $name = $_GET['username'];
    $email = $_GET['email'];
    $testtype = $_GET['testformat'];
    $testnumber = $_GET['testnumber'];
    $sql = "SELECT YourChoice, currentQuestion, DateTaken FROM anstrackuser WHERE Username = '$name' AND Email = '$email' AND TestType = '$testtype' AND TestName = 'GMAT' AND TestNumber = '$testnumber' ORDER BY anstrackuser.currentquestion ASC ";
    $result = mysql_query($sql) or die('Query failed: ' . mysql_error());
    
    $xml_output = "<?xml version=\"1.0\"?>\n"; 
    $xml_output .= "<entries>\n"; 
    
    for($x = 0 ; $x < mysql_num_rows($result) ; $x++){ 
        $row = mysql_fetch_assoc($result); 
        $xml_output .= "\t<entry>\n"; 
        $xml_output .= "\t\t<date>" . $row['DateTaken'] . "</date>\n"; 
        $xml_output .= "\t\t<currentQuestion>" . $row['currentQuestion'] . "</currentQuestion>\n"; 
    	$xml_output .= "\t\t<yourans>" . $row['YourChoice'] . "</yourans>\n"; 
        $xml_output .= "\t</entry>\n"; 
    } 
    
    $xml_output .= "</entries>"; 
    echo $xml_output;
    I can get it to work if I put name,email,testtype,and testnumber variables in the php code but when I take them out, it stops working...this tells me I am not getting the vars from flash to php

    thanks in advance
    Beyond Flash
    Your one stop web shop
    http://www.beyondflash.net

  2. #2
    Senior Member
    Join Date
    Apr 2004
    Location
    LA
    Posts
    349
    I would recommend using Firebug (a Firefox plugin) to inspect what request flash is actually making to your server. You can also alter your PHP script to log the vars received to a file like this:
    PHP Code:
    file_put_contents('log.txt'print_r($_GETTRUE)); 
    That should let you verify whether the data is actually getting through or not.

    Offhand, I see that your AS file specifies 'name' and your PHP script is looking for 'username'. Might want to double-check your var names.
    Write multiplayer games with FlashMOG 0.3.1
    Try the MyPlan Salary Calculator

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