PDA

View Full Version : Getting PHP to write XML to txt file



hectors
May 15th, 2006, 09:19 AM
Hey there, I am experimenting sending XML from Flash to a PHP page that should then write to a txt file and I can't get this to work, the txt file remains empty and I am not getting a response from the traceMe() function that displays the status. The archive.zip contains the php fla and txt.
Can anyone help?


Here's my code:
PHP:

<?php
$filename = "xmloutput.txt";
$fp = fopen( $filename,"w+");
fwrite ( $fp, "$HTTP_RAW_POST_DATA" );
fclose( $fp );
print '<?xml version="1.0"?><result>LOGIN OK</result>';
?>

Actionscript:

//A setting up the xml object to send
var loginXML = new XML();
loginElement = loginXML.createElement("LOGIN");
loginElement.attributes.username = "hectors";
loginElement.attributes.password = "itsmysecret";
loginXML.appendChild(loginElement);
// B. Construct a XML object to hold the server's reply
loginReplyXML = new XML();
loginReplyXML.onLoad = onLoginReply;
function onLoginReply(success:Boolean):Void {
if (success) {
traceMe("loginReply receieved")
} else {
traceMe("loginReply did not load")
}
}
// C. Send the LOGIN element to the server,
//place the reply in loginReplyXML
loginXML.sendAndLoad("xmlreader.php", loginReplyXML);


Thanks everyone,
Hectors

ramie
May 15th, 2006, 02:41 PM
Has the text file on the server your trying to write to got guest permissions to write and the directory also?

right click on it in your FTP client and set it to rwx rw rw

hectors
May 15th, 2006, 03:33 PM
It hasn't ramie, I checked with the hosting co and they said that it shouldnt matter as long as the full path to the files is declared. The guy from tech suppport said he had done this himself without having to change the permissions.

thanks for your help

hectors