Skip to main content
renatobox
Participant
July 11, 2011
Question

XML data ok.. but the php file doesnt do the job

  • July 11, 2011
  • 1 reply
  • 450 views

Hello

Im trying to do a guestbook. And i can read very well the XML file and show it. The problem is to save the XML after the post.

I have cheked the XML befaure it is send e it is OK. Só my problem must be de part of AS3->PHP->XML file

here is my code in FLASH...

    var urlFicheiroPHP:URLRequest = new URLRequest("mensagens.php");
    urlFicheiroPHP.data = myXML;
    urlFicheiroPHP.contentType = "text/xml";
    urlFicheiroPHP.method = URLRequestMethod.POST;
   
    var loader:URLLoader = new URLLoader();
    loader.load(urlFicheiroPHP);
    loader.addEventListener(Event.COMPLETE, loadOkFicheiroPHP);

Here is my code in PHP

<?php 
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])){ 
    $xml .= $GLOBALS["HTTP_RAW_POST_DATA"]; 
    $file = fopen("messages.xml","wb"); 
    fwrite($file, $xml);
    fclose($file); 
    echo "teste";

?>


HEEEEEEELLLLLLLLLLLPPPPPPPPP!!!!...

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 11, 2011

the urlrequest's data property must be an urlvariables instance.  try:

var urlV:URLVariables=new URLVariables();
urlV.myXML=myXML

    var urlFicheiroPHP:URLRequest = new URLRequest("mensagens.php");
   urlFicheiroPHP.data = urlV;
    urlFicheiroPHP.contentType = "text/xml";
    urlFicheiroPHP.method = URLRequestMethod.POST;
   
    var loader:URLLoader = new URLLoader();
    loader.load(urlFicheiroPHP);
    loader.addEventListener(Event.COMPLETE, loadOkFicheiroPHP);

renatobox
renatoboxAuthor
Participant
July 11, 2011

Looks like it works... but without the code you send me. The problem was mine. Its very hard to refresh the flash files... and when i chenged the code the result was the same because the file wasnt updated.

Im still testing it.. but thanks any way for the help.

kglad
Community Expert
Community Expert
July 11, 2011

you're welcome.