PDA

View Full Version : flash-php-xml


nchagial
11-27-2005, 02:52 AM
hello,

I am trying to write some data into an xml file through a php script.

In flash I call
sendData.sendAndLoad("saveXML.php", sendData, "POST");
to send a string to the php.

In the php file i do the following:

<?php

$FileName = "myXML.xml";
$FilePointer = fopen($FileName, "w+");

$output = $xml; //data sent from Flash

fwrite ($FilePointer, $output);

print $output;

fclose ($FilePointer);

?>

Everything works fine, exept that when I have " and ' symbols in the string I am sending over, in the saved XML file i get \" and \', and as a result I cannot parse the XML file correctly.

Do you know any way to overcome this?!

Thanks,
Nikos

timothy
11-27-2005, 04:08 AM
hello,

I am trying to write some data into an xml file through a php script.

In flash I call
sendData.sendAndLoad("saveXML.php", sendData, "POST");
to send a string to the php.

In the php file i do the following:

<?php

$FileName = "myXML.xml";
$FilePointer = fopen($FileName, "w+");

$output = $xml; //data sent from Flash

fwrite ($FilePointer, $output);

print $output;

fclose ($FilePointer);

?>

Everything works fine, exept that when I have " and ' symbols in the string I am sending over, in the saved XML file i get \" and \', and as a result I cannot parse the XML file correctly.

Do you know any way to overcome this?!

Thanks,
Nikos



Yo man.. in XML you canot have any special chars. That's &@!#$%^&*() so you need to encode them.

I found with Flash the best thing to do is use the urlencode(PHP) the information into the XML document and just unescape(FLASH) it inside flash.

nchagial
11-27-2005, 04:37 AM
Thanks for the reply,

i know that xml doesn't read special characters. However I only want to get rid of the slashes. I mean, I could still save it in a .txt file and get the slashes.

eg.

sendData.name = "John's";
sendData.sendAndLoad("saveTofile.php", sendData, "POST");

<?php

$FileName = "test.txt";
$FilePointer = fopen($FileName, "w+");

$output = $name; //data received from Flash

fwrite ($FilePointer, $output);

print $output;

fclose ($FilePointer);

?>

and when I open test.txt I get:

John\'s

How do I get rid of the slash!? Is it controllable in php?

CyanBlue
11-27-2005, 04:46 AM
What if you do this???
<?php

$FileName = "test.txt";
$FilePointer = fopen($FileName, "w+");

$output = stripslashes($_POST['name']) ; //data received from Flash

fwrite ($FilePointer, $output);

print $output;

fclose ($FilePointer);

?>

nchagial
11-28-2005, 10:50 PM
Thanks man!!

It worked just fine....:cool: