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