13 Replies Latest reply on Dec 16, 2009 3:15 PM by funkysoul

    ARG!! Why???

    DeyBwah Level 1

      I'm at the end of finishing this application and am completely stumped as to why ampersands (&) are displaying like, &

       

      The app is a greeting card.

       

      The text field it is displaying incorrectly in is a dynamic text field that is pulling the data from an XML file. The XML file is being generated dynamically via PHP which is pulling the data from a database.

       

      Anyone know how to display an Ampersand correctly? Or better yet, know why it ISN'T??

        • 1. Re: ARG!! Why???
          robdillon Most Valuable Participant

          Tell your textfield to use htmlText. That will probably solve it.

          1 person found this helpful
          • 2. Re: ARG!! Why???
            DeyBwah Level 1

            Tried that, still displays as &

            • 3. Re: ARG!! Why???
              DeyBwah Level 1

              Anyone else have any ideas or things I could try?

              • 4. Re: ARG!! Why???
                DeyBwah Level 1

                Please someone...

                 

                I've search Google for 2 days straight, can't seem to find anyone else having this issue.

                 

                Any help is greatly appreciated.

                 

                I double checked my XML and Database, the & is stored as a &, not &.

                 

                It appears the issue is occurring in Flash, which makes no sense.. Why would the normal & be encoded to &?? Flash has no use or need for that right?

                 

                Any help is greatly appreciated.

                • 5. Re: ARG!! Why???
                  funkysoul Level 4

                  can you post a link to the xml file you create?


                  1 person found this helpful
                  • 6. Re: ARG!! Why???
                    DeyBwah Level 1

                    Here's the AS code on the frame that pulls the XML data in...

                     

                    var ID:String = _level0.ID;


                    to_name.backgroundColor = 0x999999;

                    to_name.borderColor = 0x999999;

                    from_name.backgroundColor = 0x999999;

                    from_name.borderColor = 0x999999;


                    function loadXML(loaded) {

                    if (loaded) {

                    _root.ToName = this.firstChild.childNodes[0].firstChild;

                    _root.FromName = this.firstChild.childNodes[1].firstChild.nodeValue;

                    to_name.text = _root.ToName;

                    from_name.text = _root.FromName;

                    } else {

                      trace("file not loaded!");

                    }

                    }

                    xmlData = new XML();

                    xmlData.ignoreWhite = true;

                    xmlData.onLoad = loadXML;

                    xmlData.load("card_xml.php?ID="+ID);

                     

                    And this is the .php file that creates the XML file by pulling the data from the database...

                     

                    <?php

                    require_once('db_connection.php');


                    if (isset($_GET['ID'])){

                    $ID = $_GET['ID'];

                    $sql = "UPDATE holidaycard_2009 SET RetrieveDate = now() where ID='".$ID."'";

                    $update_sql = mysql_query($sql);

                            $sql = "select FromName,FromEmail,ToName,ToEmail,SentBy,EmailText,SentDate,RetrieveDate from holidaycard_2009 where ID ='".$ID."';";

                            $result = mysql_query($sql);

                            $output_string = '<?xml version="1.0" encoding="utf-8"?>';

                            $row = mysql_fetch_array($result, MYSQL_ASSOC);


                    $output_string .= "\r\n"."<holidaycard>";

                    $output_string .= "\r\n\t"."  <ToName><![CDATA[".$row["ToName"]."]]></ToName>";

                    //$output_string .= "\r\n\t"."  <ToEmail><![CDATA[".$row["ToEmail"]."]]></ToEmail>";

                    //$output_string .= "\r\n\t"."  <ID>".$ID."</ID>";

                    $output_string .= "\r\n\t"."  <FromName><![CDATA[".$row["FromName"]."]]></FromName>";

                    //$output_string .= "\r\n\t"."  <FromEmail><![CDATA[".$row["FromEmail"]."]]></FromEmail>";

                    //$output_string .= "\r\n\t"."  <SentBy><![CDATA[".$row["SentBy"]."]]></SentBy>";

                    $output_string .= "\r\n\t"."  <EmailText><![CDATA[".preg_replace('`[\r\n]+`',"\n",$row["EmailText"])."]]></EmailText>";

                    //$output_string .= "\r\n\t"."  <SentDate>".$row["SentDate"]."</SentDate>";

                    //$output_string .= "\r\n\t"."  <RetrieveDate>".$row["RetrieveDate"]."</RetrieveDate>";

                    $output_string .= "\r\n"."</holidaycard>";


                            echo $output_string;

                    }

                    ?>

                     

                    Is that what you were asking for?

                    • 7. Re: ARG!! Why???
                      funkysoul Level 4

                      Nope I'm asking for the XML file.. so I can load it myself in and see what happens.

                      I see you are using AS2, any special reason?

                      • 8. Re: ARG!! Why???
                        DeyBwah Level 1

                        I'm using AS2 because that's what the vendor who originally created this app used..

                         

                        Here's the XML.

                         

                        <?xml version="1.0" encoding="utf-8"?>
                        <holidaycard>
                               <ToName><![CDATA[Dave & Annette]]></ToName>
                               <FromName><![CDATA[David Rinell]]></FromName>
                               <EmailText><![CDATA[This is Japanese]]></EmailText>
                        </holidaycard>

                        • 9. Re: ARG!! Why???
                          funkysoul Level 4

                          Does that also happen in the Fromname field?

                          If no then add the .nodeValue to your toname field.

                          • 10. Re: ARG!! Why???
                            DeyBwah Level 1

                            Let me check right quick!

                            • 11. Re: ARG!! Why???
                              DeyBwah Level 1

                              Ding ding! That was it!!!

                               

                              Thanks funky man Tiago!

                               

                              Do you know why missing the .nodeValue created such a mess?

                               

                              Is that a AS2 thing or applies to AS3 as well?

                               

                              Thanks again,

                              Dey

                              • 12. Re: ARG!! Why???
                                funkysoul Level 4

                                That is only an AS2 thing, it just came up my mind when I saw it the second time..

                                Glad it worked out.

                                 

                                Don't forget to mark this post answered

                                 

                                 

                                Cheers

                                Tiago

                                • 13. Re: ARG!! Why???
                                  DeyBwah Level 1

                                  Credit is given where credit is due, thanks man!