Re: [Flashcoders] Incorrect XML from PHP to Flash
Why not just encapsulate the content in a cdata? Cheers, LF On 20/07/2011 15:35, Glen Pike wrote: http://php.net/manual/en/function.urldecode.php On 20/07/2011 15:24, Cor wrote: I am loading data from a mySQL database into Flash with PHP. But I get a string with all the tag-signs replaced with %-characters: %3C%3Fxml%20version=%221%2E0%22%20encoding%3D%22UTF%2D8%22%20%3F%3E%0A%3Cdat a%3E%3Cproject%3E%3Cproject%5Fcode%3E. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
Hi Cor, I think it is because information added to a database is usually escaped, so when you pull it out, you get the escaped string instead of what you originally typed. Most, not all php coders, will put the string through something like mysql_real_escape_string() before inserting it into the database which will produce the exact results your getting. If you apply one of the following functions to the information once pulled out, it should work. You could try.. $String = htmlspecialchars_decode($string, ENT_QUOTES); or $String = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); (There are also different options for the second and third parameters. ENT_QUOTES and 'UTF-8' can be changed to your suiting depending on what style of quoting or character set you need. But for what your needing, I think ENT_QUOTES is right. It will return p instead of quote;lt;pgt;quote; (that is what ENT_NOQUOTES does).) I suggest these links if you want to learn more about what's going on with these to see if they are a fit. http://www.php.net/manual/en/function.htmlspecialchars-decode.php http://www.php.net/manual/en/function.html-entity-decode.php Also, if you find it still not working, use one of the above functions, but then try putting the return $String text inside a CDATA []. HTH, Best, Karl On Jul 21, 2011, at 12:41 AM, Cor wrote: Is the issue due to sending URLVariables to PHP and Flash expects a value-pair back??? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Incorrect XML from PHP to Flash
Hi Karl, Thank you! I already use mysql_real_escape_string() to write to my database. And in fact I am reading the http://www.php.net/manual/... at the moment you send your mail. I do think it has to do with using URLVariables in Flash rather than my database or PHP. I have looked at the tutorials on http://www.developphp.com/view.php?tid=740t=Discover_Dynamic_XML_MySQL_PHP_ Database_Results_Loop_Tutorial and there is the same construction but his works appearantly... Best regards, Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: donderdag 21 juli 2011 8:49 To: Flash Coders List Subject: Re: [Flashcoders] Incorrect XML from PHP to Flash Hi Cor, I think it is because information added to a database is usually escaped, so when you pull it out, you get the escaped string instead of what you originally typed. Most, not all php coders, will put the string through something like mysql_real_escape_string() before inserting it into the database which will produce the exact results your getting. If you apply one of the following functions to the information once pulled out, it should work. You could try.. $String = htmlspecialchars_decode($string, ENT_QUOTES); or $String = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); (There are also different options for the second and third parameters. ENT_QUOTES and 'UTF-8' can be changed to your suiting depending on what style of quoting or character set you need. But for what your needing, I think ENT_QUOTES is right. It will return p instead of quote;lt;pgt;quote; (that is what ENT_NOQUOTES does).) I suggest these links if you want to learn more about what's going on with these to see if they are a fit. http://www.php.net/manual/en/function.htmlspecialchars-decode.php http://www.php.net/manual/en/function.html-entity-decode.php Also, if you find it still not working, use one of the above functions, but then try putting the return $String text inside a CDATA []. HTH, Best, Karl On Jul 21, 2011, at 12:41 AM, Cor wrote: Is the issue due to sending URLVariables to PHP and Flash expects a value-pair back??? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Incorrect XML from PHP to Flash {RESOLVED}
OK, so when I change the output line in my PHP from: print $response; to print returnString=$response; It traces out a correct XML: ?xml version=1.0 encoding=UTF-8 ? dataprojectproject_code![CDATA[1]]/project_codeproject_datum![C DATA[2011-07-19]]/project_datumproject_klant_nummer![CDATA[1]]/proje ct_klant_nummerproject_naam![CDATA[project naam 1]]/project_naamproject_omschrijving![CDATA[project omschrijving 1]]/project_omschrijvingproject_werkzaamheden![CDATA[project werkzh]]/project_werkzaamhedenproject_ordernummer_klant![CDATA[project ordernummer klant 1]]/project_ordernummer_klantproject_contactpersoon![CDATA[project Tinus Plosteling]]/project_contactpersoonproject_aanneemsom![CDATA[3000.00]] /project_aanneemsomproject_opdracht![CDATA[lopend]]/project_opdracht /project/data So flash expects a key-value pair!!! Thanks to all you responded to help me Best regards, Cor van Dooren www.codobyte.com -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Cor Sent: donderdag 21 juli 2011 9:04 To: 'Flash Coders List' Subject: RE: [Flashcoders] Incorrect XML from PHP to Flash Hi Karl, Thank you! I already use mysql_real_escape_string() to write to my database. And in fact I am reading the http://www.php.net/manual/... at the moment you send your mail. I do think it has to do with using URLVariables in Flash rather than my database or PHP. I have looked at the tutorials on http://www.developphp.com/view.php?tid=740t=Discover_Dynamic_XML_MySQL_PHP_ Database_Results_Loop_Tutorial and there is the same construction but his works appearantly... Best regards, Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: donderdag 21 juli 2011 8:49 To: Flash Coders List Subject: Re: [Flashcoders] Incorrect XML from PHP to Flash Hi Cor, I think it is because information added to a database is usually escaped, so when you pull it out, you get the escaped string instead of what you originally typed. Most, not all php coders, will put the string through something like mysql_real_escape_string() before inserting it into the database which will produce the exact results your getting. If you apply one of the following functions to the information once pulled out, it should work. You could try.. $String = htmlspecialchars_decode($string, ENT_QUOTES); or $String = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); (There are also different options for the second and third parameters. ENT_QUOTES and 'UTF-8' can be changed to your suiting depending on what style of quoting or character set you need. But for what your needing, I think ENT_QUOTES is right. It will return p instead of quote;lt;pgt;quote; (that is what ENT_NOQUOTES does).) I suggest these links if you want to learn more about what's going on with these to see if they are a fit. http://www.php.net/manual/en/function.htmlspecialchars-decode.php http://www.php.net/manual/en/function.html-entity-decode.php Also, if you find it still not working, use one of the above functions, but then try putting the return $String text inside a CDATA []. HTH, Best, Karl On Jul 21, 2011, at 12:41 AM, Cor wrote: Is the issue due to sending URLVariables to PHP and Flash expects a value-pair back??? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash {RESOLVED}
Good to hear. Best, Karl On Jul 21, 2011, at 2:34 AM, Cor wrote: OK, so when I change the output line in my PHP from: print $response; to print returnString=$response; It traces out a correct XML: ?xml version=1.0 encoding=UTF-8 ? dataprojectproject_code![CDATA[1]]/ project_codeproject_datum![C DATA[2011-07-19]]/project_datumproject_klant_nummer![CDATA[1]] /proje ct_klant_nummerproject_naam![CDATA[project naam 1]]/project_naamproject_omschrijving![CDATA[project omschrijving 1]]/project_omschrijvingproject_werkzaamheden![CDATA[project werkzh]]/project_werkzaamhedenproject_ordernummer_klant![CDATA [project ordernummer klant 1]]/project_ordernummer_klantproject_contactpersoon![CDATA [project Tinus Plosteling]]/project_contactpersoonproject_aanneemsom![CDATA [3000.00]] /project_aanneemsomproject_opdracht![CDATA[lopend]]/ project_opdracht /project/data So flash expects a key-value pair!!! Thanks to all you responded to help me Best regards, Cor van Dooren www.codobyte.com -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Cor Sent: donderdag 21 juli 2011 9:04 To: 'Flash Coders List' Subject: RE: [Flashcoders] Incorrect XML from PHP to Flash Hi Karl, Thank you! I already use mysql_real_escape_string() to write to my database. And in fact I am reading the http://www.php.net/manual/... at the moment you send your mail. I do think it has to do with using URLVariables in Flash rather than my database or PHP. I have looked at the tutorials on http://www.developphp.com/view.php? tid=740t=Discover_Dynamic_XML_MySQL_PHP_ Database_Results_Loop_Tutorial and there is the same construction but his works appearantly... Best regards, Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: donderdag 21 juli 2011 8:49 To: Flash Coders List Subject: Re: [Flashcoders] Incorrect XML from PHP to Flash Hi Cor, I think it is because information added to a database is usually escaped, so when you pull it out, you get the escaped string instead of what you originally typed. Most, not all php coders, will put the string through something like mysql_real_escape_string() before inserting it into the database which will produce the exact results your getting. If you apply one of the following functions to the information once pulled out, it should work. You could try.. $String = htmlspecialchars_decode($string, ENT_QUOTES); or $String = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); (There are also different options for the second and third parameters. ENT_QUOTES and 'UTF-8' can be changed to your suiting depending on what style of quoting or character set you need. But for what your needing, I think ENT_QUOTES is right. It will return p instead of quote;lt;pgt;quote; (that is what ENT_NOQUOTES does).) I suggest these links if you want to learn more about what's going on with these to see if they are a fit. http://www.php.net/manual/en/function.htmlspecialchars-decode.php http://www.php.net/manual/en/function.html-entity-decode.php Also, if you find it still not working, use one of the above functions, but then try putting the return $String text inside a CDATA []. HTH, Best, Karl On Jul 21, 2011, at 12:41 AM, Cor wrote: Is the issue due to sending URLVariables to PHP and Flash expects a value-pair back??? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Incorrect XML from PHP to Flash
The trace result of my DataProvider is: data project project_code![CDATA[1]]/project_code project_datum![CDATA[2011-07-19]]/project_datum project_naam![CDATA[project naam 1]]/project_naam project_omschrijving![CDATA[project omschrijving 1]]/project_omschrijving project_werkzaamheden![CDATA[project werkzh]]/project_werkzaamheden project_opdracht![CDATA[lopend]]/project_opdracht project_klant_nummer![CDATA[1]]/project_klant_nummer project_ordernummer_klant![CDATA[project ordernummer klant 1]]/project_ordernummer_klant project_contactpersoon![CDATA[project Tinus Plosteling]]/project_contactpersoon project_aanneemsom![CDATA[3000.00]]/project_aanneemsom /project /data Which is exactly right, and yet the columns in my DataGrid in Flash are not placed in the right order, but randomly? -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Cor Sent: donderdag 21 juli 2011 9:35 To: 'Flash Coders List' Subject: RE: [Flashcoders] Incorrect XML from PHP to Flash {RESOLVED} OK, so when I change the output line in my PHP from: print $response; to print returnString=$response; It traces out a correct XML: ?xml version=1.0 encoding=UTF-8 ? dataprojectproject_code![CDATA[1]]/project_codeproject_datum![C DATA[2011-07-19]]/project_datumproject_klant_nummer![CDATA[1]]/proje ct_klant_nummerproject_naam![CDATA[project naam 1]]/project_naamproject_omschrijving![CDATA[project omschrijving 1]]/project_omschrijvingproject_werkzaamheden![CDATA[project werkzh]]/project_werkzaamhedenproject_ordernummer_klant![CDATA[project ordernummer klant 1]]/project_ordernummer_klantproject_contactpersoon![CDATA[project Tinus Plosteling]]/project_contactpersoonproject_aanneemsom![CDATA[3000.00]] /project_aanneemsomproject_opdracht![CDATA[lopend]]/project_opdr acht /project/data So flash expects a key-value pair!!! Thanks to all you responded to help me Best regards, Cor van Dooren www.codobyte.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash {RESOLVED}
Cor skriver: OK, so when I change the output line in my PHP from: print $response; to print returnString=$response; So flash expects a key-value pair!!! Now the real question is, why is Flash expecting that format to begin with? You shouldn't change your php code. You should change the actionscript code. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Incorrect XML from PHP to Flash {RESOLVED}
Thank you. I have: var myXML:XML = XML(e.target.data.returnString); trace(myXML); outputs correctly: -- data project project_code![CDATA[1]]/project_code project_datum![CDATA[2011-07-19]]/project_datum project_naam![CDATA[project naam 1]]/project_naam project_omschrijving![CDATA[project omschrijving 1]]/project_omschrijving project_werkzaamheden![CDATA[project werkzh]]/project_werkzaamheden project_opdracht![CDATA[lopend]]/project_opdracht project_klant_nummer![CDATA[1]]/project_klant_nummer project_ordernummer_klant![CDATA[project ordernummer klant 1]]/project_ordernummer_klant project_contactpersoon![CDATA[project Tinus Plosteling]]/project_contactpersoon project_aanneemsom![CDATA[3000.00]]/project_aanneemsom /project project project_code![CDATA[2]]/project_code project_datum![CDATA[2011-07-21]]/project_datum project_naam![CDATA[naam 2]]/project_naam project_omschrijving![CDATA[omsch 2]]/project_omschrijving project_werkzaamheden![CDATA[werk 2]]/project_werkzaamheden project_opdracht![CDATA[geen order]]/project_opdracht project_klant_nummer![CDATA[2]]/project_klant_nummer project_ordernummer_klant![CDATA[ord-kl 2]]/project_ordernummer_klant project_contactpersoon![CDATA[contp 2]]/project_contactpersoon project_aanneemsom![CDATA[]]/project_aanneemsom /project /data -- But now my DataGrid does not show the result in the right order. It even shows different on refresh/reload? regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: donderdag 21 juli 2011 15:10 To: Flash Coders List Subject: Re: [Flashcoders] Incorrect XML from PHP to Flash {RESOLVED} Cor skriver: OK, so when I change the output line in my PHP from: print $response; to print returnString=$response; So flash expects a key-value pair!!! Now the real question is, why is Flash expecting that format to begin with? You shouldn't change your php code. You should change the actionscript code. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash {RESOLVED}
Cor skriver: Thank you. I have: var myXML:XML = XML(e.target.data.returnString); You should have XML(loader.data). Use the URLLoaderDataFormat.TEXT mode, not the URLLoaderDataFormat.VARIABLES mode. As for the ordering, did you request any specific order at any time in the chain? You did not in the sql query, you did not attempt to reorder things in php and you did not attempt to reorder things in actionscript. Ask for the items in the table in a specific order in the sql query. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Incorrect XML from PHP to Flash
I am loading data from a mySQL database into Flash with PHP. But I get a string with all the tag-signs replaced with %-characters: %3C%3Fxml%20version=%221%2E0%22%20encoding%3D%22UTF%2D8%22%20%3F%3E%0A%3Cdat a%3E%3Cproject%3E%3Cproject%5Fcode%3E. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
http://php.net/manual/en/function.urldecode.php On 20/07/2011 15:24, Cor wrote: I am loading data from a mySQL database into Flash with PHP. But I get a string with all the tag-signs replaced with %-characters: %3C%3Fxml%20version=%221%2E0%22%20encoding%3D%22UTF%2D8%22%20%3F%3E%0A%3Cdat a%3E%3Cproject%3E%3Cproject%5Fcode%3E. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
Your php code is broken then. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Incorrect XML from PHP to Flash
This is it without the DB-conection ofcourse: if (isset($_POST['sendRequest']) $_POST['sendRequest'] == read_all_projects) { $sql = SELECT * FROM tbl_projecten; $result = mysql_query($sql); header(Content-type: text/xml); $response ='?xml version=1.0 encoding=UTF-8 ?'; $response .=\ndata; while($row = mysql_fetch_object($result)){ $response.='project'; $response.='project_code![CDATA['.$row-project_code.']]/project_code' ; $response.='project_datum![CDATA['.$row-project_datum.']]/project_datu m'; $response.='project_klant_nummer![CDATA['.$row-project_klant_nummer.']] /project_klant_nummer'; $response.='project_naam![CDATA['.$row-project_naam.']]/project_naam' ; $response.='project_omschrijving![CDATA['.$row-project_omschrijving.']] /project_omschrijving'; $response.='project_werkzaamheden![CDATA['.$row-project_werkzaamheden.'] ]/project_werkzaamheden'; $response.='project_ordernummer_klant![CDATA['.$row-project_ordernummer_ klant.']]/project_ordernummer_klant'; $response.='project_contactpersoon![CDATA['.$row-project_contactpersoon. ']]/project_contactpersoon'; $response.='project_aanneemsom![CDATA['.$row-project_aanneemsom.']]/pr oject_aanneemsom'; $response.='project_opdracht![CDATA['.$row-project_opdracht.']]/projec t_opdracht'; $response.='/project'; } $response.=/data; print $response; } Best regards, Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: woensdag 20 juli 2011 16:37 To: Flash Coders List Subject: Re: [Flashcoders] Incorrect XML from PHP to Flash Your php code is broken then. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
Have you tried without wrapping it in a CDATA tag? Could this be converting the tags to ASCII? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
Did you even look at the code he posted? The code already does that! As for the code itself, while I do not aprove of using string concatenation to build xml, that seems to be ok. You seem to have some sort of dodgey filter running somewhere later in the chain. I recommend using a http request sniffer, like Fiddler, to check when the incorrect encoding is performed. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
Hmm, maybe not URL encoding. What happens when you call the php page directly - in Firefox, does it show you the XML, or do you have to view the source? (The former would mean firefox considered it valid xml) Does the XML show all the url-encoded characters, or is it just in Flash? As an aside to help with your XML, you could do this - it might not help your encoding, check the results by echoing them out I guess? //Don't worry about \n and whitespace in your $response var, the DOMDocument will sort it out ;) //You don't need to include the ?xml? tag either. $response = //... $doc = new DOMDocument(); $doc-preserveWhiteSpace = false; $doc-formatOutput = true; $doc-loadXML($response); echo $doc-saveXML(); Another trick might be to do this to make your output a bit more easy to automate: $fields = array(code, datum, klant_nummer, ...); while($row = mysql_fetch_assoc($result)) { $response .=project; foreach($fields as $field) { $response .= project_${field}![CDATA[ .$row[project_ .$field] .]]/project_${field}; } HTH Glen On 20/07/2011 15:39, Cor wrote: This is it without the DB-conection ofcourse: if (isset($_POST['sendRequest']) $_POST['sendRequest'] == read_all_projects) { $sql = SELECT * FROM tbl_projecten; $result = mysql_query($sql); header(Content-type: text/xml); $response ='?xml version=1.0 encoding=UTF-8 ?'; $response .=\ndata; while($row = mysql_fetch_object($result)){ $response.='project'; $response.='project_code![CDATA['.$row-project_code.']]/project_code' ; $response.='project_datum![CDATA['.$row-project_datum.']]/project_datu m'; $response.='project_klant_nummer![CDATA['.$row-project_klant_nummer.']] /project_klant_nummer'; $response.='project_naam![CDATA['.$row-project_naam.']]/project_naam' ; $response.='project_omschrijving![CDATA['.$row-project_omschrijving.']] /project_omschrijving'; $response.='project_werkzaamheden![CDATA['.$row-project_werkzaamheden.'] ]/project_werkzaamheden'; $response.='project_ordernummer_klant![CDATA['.$row-project_ordernummer_ klant.']]/project_ordernummer_klant'; $response.='project_contactpersoon![CDATA['.$row-project_contactpersoon. ']]/project_contactpersoon'; $response.='project_aanneemsom![CDATA['.$row-project_aanneemsom.']]/pr oject_aanneemsom'; $response.='project_opdracht![CDATA['.$row-project_opdracht.']]/projec t_opdracht'; $response.='/project'; } $response.=/data; print $response; } Best regards, Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: woensdag 20 juli 2011 16:37 To: Flash Coders List Subject: Re: [Flashcoders] Incorrect XML from PHP to Flash Your php code is broken then. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
Sorry, I meant to say NOT wrapping. Problem is beyond that though. On Wed, Jul 20, 2011 at 10:58 AM, Henrik Andersson he...@henke37.cjb.netwrote: Did you even look at the code he posted? The code already does that! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
Hi Cor, I think you will want to put htmlspecialchars() around what comes out of the database. $String = htmlspecialchars($database_result); HTH, Best, Karl On Jul 20, 2011, at 9:24 AM, Cor wrote: I am loading data from a mySQL database into Flash with PHP. But I get a string with all the tag-signs replaced with %-characters: %3C%3Fxml%20version=%221%2E0%22%20encoding%3D%22UTF%2D8%22%20%3F%3E% 0A%3Cdat a%3E%3Cproject%3E%3Cproject%5Fcode%3E. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Incorrect XML from PHP to Flash
Karl DeSaulniers skriver: Hi Cor, I think you will want to put htmlspecialchars() around what comes out of the database. More like using a proper XML generating library. I recommend the DOM php extension. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Incorrect XML from PHP to Flash
It looks good directly it is just in Flash: This XML file does not appear to have any style information associated with it. The document tree is shown below. dataprojectproject_code1/project_codeproject_datum2011-07-19/proj ect_datumproject_klant_nummer1/project_klant_nummerproject_naamprojec t naam 1/project_naamproject_omschrijvingproject omschrijving 1/project_omschrijvingproject_werkzaamhedenproject werkzh/project_werkzaamhedenproject_ordernummer_klantproject ordernummer klant 1/project_ordernummer_klantproject_contactpersoonproject Tinus Plosteling/project_contactpersoonproject_aanneemsom3000.00/project_aann eemsomproject_opdrachtlopend/project_opdracht/project/data I will look at your suggestion now. Due to my time zone, I had to take a beauty sleep. :-) Best regards, Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: woensdag 20 juli 2011 16:58 To: Flash Coders List Subject: Re: [Flashcoders] Incorrect XML from PHP to Flash Hmm, maybe not URL encoding. What happens when you call the php page directly - in Firefox, does it show you the XML, or do you have to view the source? (The former would mean firefox considered it valid xml) Does the XML show all the url-encoded characters, or is it just in Flash? As an aside to help with your XML, you could do this - it might not help your encoding, check the results by echoing them out I guess? //Don't worry about \n and whitespace in your $response var, the DOMDocument will sort it out ;) //You don't need to include the ?xml? tag either. $response = //... $doc = new DOMDocument(); $doc-preserveWhiteSpace = false; $doc-formatOutput = true; $doc-loadXML($response); echo $doc-saveXML(); Another trick might be to do this to make your output a bit more easy to automate: $fields = array(code, datum, klant_nummer, ...); while($row = mysql_fetch_assoc($result)) { $response .=project; foreach($fields as $field) { $response .= project_${field}![CDATA[ .$row[project_ .$field] .]]/project_${field}; } HTH Glen On 20/07/2011 15:39, Cor wrote: This is it without the DB-conection ofcourse: if (isset($_POST['sendRequest']) $_POST['sendRequest'] == read_all_projects) { $sql = SELECT * FROM tbl_projecten; $result = mysql_query($sql); header(Content-type: text/xml); $response ='?xml version=1.0 encoding=UTF-8 ?'; $response .=\ndata; while($row = mysql_fetch_object($result)){ $response.='project'; $response.='project_code![CDATA['.$row-project_code.']]/project_code' ; $response.='project_datum![CDATA['.$row-project_datum.']]/project_datu m'; $response.='project_klant_nummer![CDATA['.$row-project_klant_nummer.']] /project_klant_nummer'; $response.='project_naam![CDATA['.$row-project_naam.']]/project_naam' ; $response.='project_omschrijving![CDATA['.$row-project_omschrijving.']] /project_omschrijving'; $response.='project_werkzaamheden![CDATA['.$row-project_werkzaamheden.'] ]/project_werkzaamheden'; $response.='project_ordernummer_klant![CDATA['.$row-project_ordernummer_ klant.']]/project_ordernummer_klant'; $response.='project_contactpersoon![CDATA['.$row-project_contactpersoon. ']]/project_contactpersoon'; $response.='project_aanneemsom![CDATA['.$row-project_aanneemsom.']]/pr oject_aanneemsom'; $response.='project_opdracht![CDATA['.$row-project_opdracht.']]/projec t_opdracht'; $response.='/project'; } $response.=/data; print $response; } Best regards, Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: woensdag 20 juli 2011 16:37 To: Flash Coders List Subject: Re: [Flashcoders] Incorrect XML from PHP to Flash Your php code is broken then. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Incorrect XML from PHP to Flash
Is the issue due to sending URLVariables to PHP and Flash expects a value-pair back??? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders