Strange problem at loading xml with greek fonts

Hello to all,

I have a strange problem and i hope you can give me some help!!

I have a database in mysql, and I’m creating a search engine in as3 which will find the string in the database.

With other words: AS3 -> (with POST) php -> connect to mysql and query -> return the result -> generate xml -> as3 again.

The code in as3 is:


    stop();

    var myvariables:URLVariables = new URLVariables();
    var myLoader:URLLoader = new URLLoader();
    var myURLRequest:URLRequest = new URLRequest("results.php")
    var searchXML:XML = new XML();
    var searchXMLLoader:URLLoader = new URLLoader();

    gosearch.buttonMode = true;
    gosearch.addEventListener(MouseEvent.MOUSE_DOWN, gosearchdown);

    function gosearchdown(e:MouseEvent):void
    {
       myURLRequest.method = URLRequestMethod.POST;
       myURLRequest.data = myvariables;
       myvariables.word = search.text;
       myLoader.addEventListener(Event.COMPLETE, isDone);
       myLoader.load(myURLRequest);
    }



    function isDone(e:Event):void
    {
       searchXMLLoader.addEventListener(Event.COMPLETE, LoadsearchXML);
       searchXMLLoader.load(new URLRequest("results.php?word=" + search.text + "&" + new Date().getTime() ));
       searchXML.ignoreWhite = true;   
       navigateToURL(myURLRequest, "_blank" );   
    }

    function LoadsearchXML(e:Event):void
    {
       searchXML = new XML(e.target.data);
    }

It’s working FINE with latins characters and numbers. BUT when i use greek fonts in the search engine, the .php file generates FINE the .xml with correct results, BUT as3 CANT load the xml with this error:

TypeError: Error #1088: The markup in the document following the root element must be well-formed.
at search_fla::MainTimeline/loadsearchXML()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

:shock: :shock:

Somebody can explain me? Thank very much for your time! Looking forward for a response :idea:

P.S.: I have written --> header(“Content-type: text/xml”); and <?xml version=\"1.0\" encoding=\"UTF-8\"?>
"; at the .php file… I tried also the unescape(search.text) but nothing…

P.S.2: the .php is here:

<?php
$results = $_GET['word'];
       
include 'connect.php';

$query2 = "SELECT * FROM `product`";
$result2 = mysql_query($query2) or die(mysql_error());

header("Content-type: text/xml");


    $XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
";
    $XML .= "<product>
";
    
              
              while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC))
              {
                $vowels = array("&#940;", "&#941;","&#942;", "&#943;", "&#973;", "&#972;", "&#974;", "&#970;", "&#912;", "&#971;", "&#944;");
                $vowelsok = array("&#945;", "&#949;", "&#951;", "&#953;", "&#965;", "&#959;", "&#969;", "&#953;", "&#953;", "&#965;", "&#965;");
                $counter = 1;

                while($counter<=11)
                 {
                    $r_ok = str_replace($vowels, $vowelsok, $row2['Pname']);
                    $r2_ok = str_replace($vowels, $vowelsok, $results);
                    $r = mb_convert_case($r_ok, MB_CASE_LOWER, "utf-8");
                    $r2 = mb_convert_case($r2_ok, MB_CASE_LOWER, "utf-8");
                    $counter++;
                }
        
                if (stristr($r,$r2) != "")
                {
                    $row2 = str_replace("&", "&amp;", $row2);
                    $row2 = str_replace("<", "&lt;", $row2);
                    $row2 = str_replace(">", "&gt;", $row2);
                    $row2 = str_replace("\"", "&quot;", $row2);
                    // creates the "<tag>contents</tag>" representing the column
                    $XML .= "	<r>
";
                    $XML .= "		<it name=\"id\">". $row2['productId'] . "</it>
";
                    $XML .= "		<it name=\"name\">". $row2['Pname'] . "</it>
";
                    $XML .= "		<it name=\"category\">". $row2['Pcategory'] . "</it>
";
                    $XML .= "		<it name=\"subcategory\">". $row2['Psubcategory'] . "</it>
";    
                    $XML .= "		<it name=\"price\">". $row2['price'] . "</it>
";                        
                    $XML .= "		<it name=\"photo\">". $row2['photo'] . "</it>
";        
                    $XML .= "	</r>
";
                  }
                       }    
            $XML .= "</product>";
            print $XML;
                    // output the whole XML string
?>

P.S.3: Sorry for my bad english. :smiley: