# Sending data to PhP script (help with AS2-AS3 conversion)

**URL:** https://forum.kirupa.com/t/sending-data-to-php-script-help-with-as2-as3-conversion/293871
**Category:** flash
**Created:** [August 5, 2009, 6:57am UTC](https://forum.kirupa.com/t/sending-data-to-php-script-help-with-as2-as3-conversion/293871 "2009-08-05T06:57:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![andrewlong](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@andrewlong](https://forum.kirupa.com/u/andrewlong)
#### Post date: [August 5, 2009, 6:57am UTC](https://forum.kirupa.com/t/sending-data-to-php-script-help-with-as2-as3-conversion/293871/1 "2009-08-05T06:57:00Z")

</div>

I have a project that will take and XML string and send it to a PhP script that will stores it in a .CSV . The code navigates the browser to the php file which then automatically navigates the user to a debreifing page. I took a colleagues AS2 script and tried to translate it to AS3. Here are the two codes.  
AS2:

```auto

 getURL(parsefilename, "_self");
}
  datastring = datastring + "</VARIABLES>";
  var myXML:XML = new XML(datastring);
  myXML.contentType = "text/xml";
  myXML.send(parsefilename, "_self");

```

AS3:

```auto

var dataStringXML:XML = new XML(dataString);
var xmlResponse:XML;
var xmlURLReq:URLRequest = new URLRequest(parsefilename);

xmlURLReq.data = dataStringXML;
xmlURLReq.contentType = "text/xml";
xmlURLReq.method = URLRequestMethod.POST;
var xmlSendLoad:URLLoader = new URLLoader();
xmlSendLoad.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
xmlSendLoad.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
xmlSendLoad.load(xmlURLReq);
navigateToURL(xmlURLReq, "_self")
function onComplete(evt:Event):void {
    try {
        xmlResponse = new XML(evt.target.data);
        trace(xmlResponse);
        removeEventListener(Event.COMPLETE, onComplete);
        removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
    } catch (err:TypeError) {
        trace("Parser Error " + err.message);
    }
}
function onIOError(evt:IOErrorEvent):void {
   trace("An error occurred when attempting to load the XML.
" + evt.text);
}

```

The biggest problem I am having currently is that the CSV is showing two entries everytime the code executes. It works when I put the navtourl function in the oncomplete (i did this thinking i want to nav after all the code has finished), but then it never nav’s.

Any tips or suggestions are appreciated. My code is the result of a lot of forum reading and trial and error, so I dont know a lot about how it works. There is probably unneeded stuff and the like. If anyone is feeling especially helpful and want to suggest a more lean script I would love that.
