# Saving xml via php

**URL:** <https://forum.kirupa.com/t/saving-xml-via-php/255557>\
**Category:** Uncategorized\
**Created:** [March 24, 2008, 7:36pm UTC](https://forum.kirupa.com/t/saving-xml-via-php/255557 "2008-03-24T19:36:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonhallewell](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jonhallewell](https://forum.kirupa.com/u/jonhallewell)\
**Post date:** [March 24, 2008, 7:36pm UTC](https://forum.kirupa.com/t/saving-xml-via-php/255557/1 "2008-03-24T19:36:21Z")

</div>

I’ve imported an XML file into flash and edited it there successfully. I’m trying to send the edited version back to the server via PHP - but keep getting the following error:

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.  
at Error$/throwError()  
at [flash.net](http://flash.net)::URLVariables/decode()  
at [flash.net](http://flash.net)::URLVariables()  
at [flash.net](http://flash.net)::URLLoader/onComplete()

Can someone PLEASE HELP - I’m really a designer who hasn’t done any coding for many years.

Here’s my send function in flash:

function sendData():void {  
trace(“got this far”);  
var myData:URLRequest = new URLRequest(“[http://mangotang.com/savexml.php](http://mangotang.com/savexml.php)”);  
myData.method = URLRequestMethod.POST;  
var variables:URLVariables = new URLVariables();  
variables.content = xml.toXMLString();  
myData.data = variables;  
var loader:URLLoader = new URLLoader();  
loader.dataFormat = URLLoaderDataFormat.VARIABLES;  
loader.addEventListener(Event.COMPLETE, dataOnLoad);  
loader.load(myData);  
}

and here’s the php file:

\<?php  
$filename = “notices.xml”;  
$thedata = $\_POST[‘content’];  
$domobject = new DomDocument(‘1.0’,‘utf-8’);  
$content = $domobject . $thedata;  
$filehandle = fopen($filename, ‘w’);  
if(fwrite($filehandle, $content)) echo “writing=Ok&”;  
else echo “writing=Error&”  
fclose($filehandle);  
?\>
