Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-04-2005, 02:26 AM   #1
Phil_NZ
Registered User
 
Join Date: Jul 2005
Posts: 3
Default Problem sending special characters to PHP

Hey team,

I'm having a problem sending special characters out of my Flash client to PHP, via XML.

For example, I compile an input field that takes free text into an XML node, and send it to my PHP script. But in PHP, it breaks at any apostrophe when parsed, because the PHP parser is hitting &apos strings. The PHP returns any string data in a CDATA tag, and I handle those as usual.

However, if I try to compile a CDATA tag inside Flash to send back to PHP, naturally it just strips it out.

Here's a function I'm using to compile the XML:

ActionScript Code:
function makeCDataNode(nid,nname,nvalue) {         var nvalue = ("<![CDATA["+nvalue+"]]>")         var tXML = new XML("<selection><id>"+nid+"</id><fieldname>"+nname+"</fieldname><value>"+nvalue+"</value></selection>");         return tXML; }


But no joy - Flash strips the CDATA tag when compiling, and we're left with &apos for any apostrophes that are passed into nvalue.

Am I missing something, or should I use a different approach entirely (rather than CDATA) when sending special characters *out* of Flash? Or does this issue really need to be handled at the PHP end? (Note: I'm not doing the PHP personally). My preference would be for a Flash-side solution, so I have control over this issue in the future.

Thanks in advance,
Phil
Phil_NZ is offline   Reply With Quote
Old 08-04-2005, 02:47 AM   #2
MDiddy
Member
 
Join Date: Aug 2004
Posts: 81
Default

Hi
Instead of using CDATA in that manner, what I do is use the escape command ot URL-encode a given string. If you've never used it, the syntax is pretty easy:

ActionScript Code:
var nvalue = escape(my_value);

If you XML file is rendered by flash, just call unescape and flash will put that text back to normal.

HTH
MDiddy is offline   Reply With Quote
Old 08-08-2005, 09:36 PM   #3
Phil_NZ
Registered User
 
Join Date: Jul 2005
Posts: 3
Default

Hi MDiddy,

Bingo. That worked a treat... and the PHP parser at the other end is interpreting the URL encoded string.

Thanks heaps - another little trick to file in the archives!



Cheers,
Phil
Phil_NZ is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:27 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.