I was going to say - there is (in my opinion) no need, apart form making things harder than they need to be, to use XML and PHP together - i have yet to come across a good reason for mixing the two.
And adding an extra markup langauge into the equation certainly won't help.
To send an array to php do this:
(This was a drawing application i built that stored the users x and y coordinates in a MySQL db).
Say i had 2 arrays like this:
array1:
548.95
547.95
545.95
541.95
535.95
528.95
521.95
513.95
505.95
496.95
487.95
477.95
470.95
array2:
548.95
547.95
545.95
541.95
535.95
528.95
521.95
513.95
505.95
496.95
487.95
477.95
470.95
ActionScript Code:
_root.saveArray.onRelease = function ()
{
imageSend_lv = new LoadVars();
imageBack_lv = new LoadVars();
imageSend.xCoord = mousePointsX;
imageSend.yCoord = mousePointsY;
imageSend.onLoad = function (successGo)
{
if(successGo)
{
trace("data sent");
}
}
imageBack.onLoad = function (successBack)
{
if(successBack)
{
trace("data saved");
}
else
}
imageSend_lv.sendAndLoad("drawing.php", imageBack_lv, "POST");
}
You can receive the array sent to the php file as a normal variable, just like any other php variable being received.
But...say you wanted to get the data back out of the database into php, ready to send back to flash, well, you get it like this (using the same example):
PHP Code:
$tmpStrX = "";
$tmpStrY = "";
$resData = mysql_db_query ("images","SELECT draw_x, draw_y FROM table_name WHERE draw_name = '$varName'");
while ($entry = mysql_fetch_array ($resData))
{
$tmpStrX = $tmpStrX . $entry["draw_x"] . ",";
$tmpStrY = $tmpStrY . $entry["draw_y"] . ",";
}
mysql_free_result($resData);
print "myNamesX=$tmpStrX";
print "&";
print "myNamesY=$tmpStrY";
print "&";
Then you'd receive that in flash like:
ActionScript Code:
image_lv = new LoadVars();
image_lvBack = new LoadVars();
image_lv.varName = getUser(this._name, storeNames);
image_lv.onLoad = function (checkPlease)
{
if(checkPlease)
{
_root.banner.myStatus.text = "Work of art retrieved";
}
}
image_lvBack.onLoad = function ()
{
unescape(this);
_root.banner.myStatus.text = "Work of art retrieved";
}
image_lv.sendAndLoad("genDraw_x.php", image_lvBack, "POST");
storeX = image_lvBack.myNamesX.split(",");
storeY = image_lvBack.myNamesY.split(",");
and hey presto!!! You have an array called storeX and storeY - with the data serialised! and array from flash > php > mysql > php > flash.
No need for nasty XML.
Regards, snapple