12 Replies Latest reply on Mar 19, 2010 8:53 PM by Gibjohn

    Please help with XML parser failure: Unterminated element

    G009 Level 1

      Hello friends i need you help removing [RPC Fault faultString="Error #1096: XML parser failure: Unterminated element." faultCode="Client.CouldNotDecode" faultDetail="null"] error. I really dont knw why and how i'm getting this error.

      I am attaching my php as well as mxml code here. Please help with this. its very urgent. Thanks guys in advance.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
      xmlns="*" creationComplete="userRequest.send()">
          <mx:Script>
              <![CDATA[
                  [Bindable]
                  public var teamName:String="Atlanta";
              ]]>
          </mx:Script>
         
          <mx:DataGrid id="dgUserRequest" width="500" x="22" y="128" dataProvider="{userRequest.lastResult.games.game}">
              <mx:columns>
                  <mx:DataGridColumn headerText="User ID" dataField="baseball"/>
              </mx:columns>
          </mx:DataGrid>
         
          <mx:HTTPService id="userRequest" url="http://localhost/tickertech/test.php">
              <mx:request xmlns="">
                  <teamname>{teamName}</teamname>
              </mx:request>
          </mx:HTTPService>
      </mx:WindowedApplication>

       

      ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ -------------------

       

       


      <?php

       

      $id = "Atlanta";
      //$id2 = $_GET["teamname"];
      //print_r($_GET);
      $today = date("Y-m-d");
      $yesterday = date("Y-m-d", strtotime("yesterday"));
      $day = $yesterday;

       

      $MyConnection = mysql_connect("localhost","root","merlin");

       

                  if (!$MyConnection)
                        {
                        die('Could not connect: ' . mysql_error());
                        }
                                                                          //Assuming Database SportsFeeds and table Sports are already created in MySQL
                  mysql_select_db("tickertech", $MyConnection);
                  $query = "SELECT * FROM baseball WHERE hometeam='$id' AND date='$today' OR awayteam='$id' AND date='$today';";
                  $myquery = mysql_query($query);

       

              if(mysql_num_rows($myquery)>0)
              {
                  while( $scoreStats = mysql_fetch_object($myquery))
                  {
                      $date = $scoreStats->date;
                      $startTime =$scoreStats->starttime;
                      $endTime = $scoreStats->endtime;
                      $status = $scoreStats->status;
                      $homeTeam = $scoreStats->hometeam;
                      $awayTeam = $scoreStats->awayteam;
                      $matchResult = $scoreStats->matchresult;
                      $runsForHomeTeam = $scoreStats->runsForHomeTeam;
                      $hitsForHomeTeam = $scoreStats->hitsForHomeTeam;
                      $runsForAwayTeam = $scoreStats->runsForAwayTeam;
                      $hitsForAwayTeam = $scoreStats->hitsForAwayTeam;
                      $year = $scoreStats->year;
                      $month = $scoreStats->month;
                      $day = $scoreStats->day;

       

                      $hometeam="hometeam";
                      $awayteam="awayteam";

       

                      $startTime = explode(":",$startTime);
                      $time = $startTime[0].":".$startTime[1];

       

                      $tempResult = $date."<br>".$startTime."<br>".$endTime."<br>".$status."<br>".$homeTeam." v/s ".$awayTeam."<br> Runs for Home Team ".$runsForHomeTeam."<br> Hits for Home Team ".$hitsForHomeTeam."<br> Match won by ".$matchResult;
                      print ($tempResult);

       


                                                  //Check if match is complete
                      if($status == "complete")
                      {
                                          //Checking if users team is home team or away team
                          if ($homeTeam == $id && $matchResult == "hometeam")
                          {
                              $message = "Today ".$homeTeam." won against ".$awayTeam." with score of ".$runsForHomeTeam." to ".$runsForAwayTeam.".";
                              $message = $message."In this match ".$homeTeam." scored ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits ";
                              $message = $message." and ".$awayTeam." made ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits";
                          }

       


                          if ($homeTeam == $id && $matchResult == $awayteam)
                          {

       

                              $message = "Today ".$homeTeam." got defeated by ".$awayTeam." with score of ".$runsForAwayTeam." to ".$runsForHomeTeam;
                              $message = $message." In this match ".$homeTeam." scored ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits ";
                              $message = $message." and ".$awayTeam." made ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits";
                          }

       

                          if ($awayTeam == $id && $matchResult == "awayteam")
                          {
                              $message = "Today ".$awayTeam." defeated ".$homeTeam." with score of ".$runsForAwayTeam." to ".$runsForHomeTeam.".";
                              $message = $message."In this match ".$awayTeam." scored ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits ";
                              $message = $message." and ".$homeTeam." scored ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits";
                          }

       

                          if ($awayTeam == $id && $matchResult == "hometeam")
                          {
                              $message = "Today ".$awayTeam." lost to ".$homeTeam." with score of ".$runsForAwayTeam." to ".$runsForHomeTeam.".";
                              $message = $message."In this match ".$awayTeam." scored ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits ";
                              $message = $message." and ".$homeTeam." made ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits";
                          }
                          else
                          {
                              $message = "Today ".$homeTeam." got defeated by ".$awayTeam." with score of ".$runsForAwayTeam." to ".$runsForHomeTeam;
                              $message = $message."In this match ".$homeTeam." scored ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits ";
                              $message = $message." and ".$awayTeam." made ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits";

       


                          }

       

                          print ($message);

       


                      } // End of If statement
                      else
                      {
                                                      //Check if match is scheduled
                          if($status == "scheduled")
                          {
                              if ($homeTeam == $id)
                              {
                                  $message = "Today ".$homeTeam." has match scheduled against ".$awayTeam." at ".$time;

       

                              }

       

                              if ($awayTeam == $id)
                              {
                                  $message = "Today ".$awayTeam." has match scheduled against ".$homeTeam." at ".$time;

       

                              }
                              print ($message);

       

                          }

       

                          else            //Check if match is in-progress
                          {
                              if ($homeTeam == $id)
                              {
                                  $message = "Today ".$homeTeam." is playing against ".$awayTeam." and match started at ".$time;
                                  $message = $message."Right now ".$homeTeam." has ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits ";
                                  $message = $message." and ".$awayTeam." is with ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits";
                              }

       

                              if ($awayTeam == $id)
                              {
                                  $message = "Today ".$awayTeam." is playing against ".$homeTeam." and match started ".$time;
                                  $message = $message."Right now ".$awayTeam." has ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits ";
                                  $message = $message." and ".$homeTeam." is with ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits";
                              }
                              print ($message);

       

                          }

       

                      }

       


                  }
              }

       

       

       

                  //Match result for yesterdays match

       

                  $query = "SELECT * FROM baseball WHERE hometeam='$id' AND date='$yesterday' OR awayteam='$id' AND date='$yesterday';";
                  $myquery = mysql_query($query);

       

              if(mysql_num_rows($myquery)>0)
                      {
                          while( $scoreStats = mysql_fetch_object($myquery))
                          {
                              $date = $scoreStats->date;
                              $startTime =$scoreStats->starttime;
                              $endTime = $scoreStats->endtime;
                              $status = $scoreStats->status;
                              $homeTeam = $scoreStats->hometeam;
                              $awayTeam = $scoreStats->awayteam;
                              $matchResult = $scoreStats->matchresult;
                              $runsForHomeTeam = $scoreStats->runsForHomeTeam;
                              $hitsForHomeTeam = $scoreStats->hitsForHomeTeam;
                              $runsForAwayTeam = $scoreStats->runsForAwayTeam;
                              $hitsForAwayTeam = $scoreStats->hitsForAwayTeam;
                              $year = $scoreStats->year;
                              $month = $scoreStats->month;
                              $day = $scoreStats->day;

       


                              $tempResult = $date."<br>".$startTime."<br>".$endTime."<br>".$status."<br>".$homeTeam." v/s ".$awayTeam."<br> Runs for Home Team ".$runsForHomeTeam."<br> Hits for Home Team ".$hitsForHomeTeam."<br> Runs for Away Team ".$runsForAwayTeam."<br> Hits for Away Team ".$hitsForAwayTeam."<br> Match won by ".$matchResult."<br><br><br>";
                              print ($tempResult);
                              if($status == "complete")
                              {
                                          //Checking if users team is home team or away team
                                  if ($homeTeam == $id && $matchResult == "hometeam")
                                  {
                                      $ymessage = "Today ".$homeTeam." won against ".$awayTeam." with score of ".$runsForHomeTeam." to ".$runsForAwayTeam.".";
                                      $ymessage = $ymessage."In this match ".$homeTeam." scored ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits ";
                                      $ymessage = $ymessage." and ".$awayTeam." made ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits";
                                  }

       


                                  if ($homeTeam == $id && $matchResult == "awayteam")
                                  {
                                      echo "hello";
                                      $ymessage = "Today ".$homeTeam." got defeated by ".$awayTeam." with score of ".$runsForAwayTeam." to ".$runsForHomeTeam;
                                      $ymessage = $ymessage."In this match ".$homeTeam." scored ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits ";
                                      $ymessage = $ymessage." and ".$awayTeam." made ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits";
                                  }

       

                                  if ($awayTeam == $id && $matchResult == "awayteam")
                                  {
                                      $ymessage = "Today ".$awayTeam." defeated ".$homeTeam." with score of ".$runsForAwayTeam." to ".$runsForHomeTeam.".";
                                      $ymessage = $ymessage."In this match ".$awayTeam." scored ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits ";
                                      $ymessage = $ymessage." and ".$homeTeam." scored ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits";
                                  }

       

                                  if ($awayTeam == $id && $matchResult == "hometeam")
                                  {
                                      $ymessage = "Today ".$awayTeam." lost to ".$homeTeam." by ".$runsForAwayTeam." to ".$runsForHomeTeam." runs.";
                                      $ymessage = $ymessage."In this match ".$awayTeam." scored ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits ";
                                      $ymessage = $ymessage." and ".$homeTeam." made ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits";
                                  }
                                  else
                                  {
                                      $ymessage = "Today ".$homeTeam." got defeated by ".$awayTeam." with score of ".$runsForAwayTeam." to ".$runsForHomeTeam.". ";
                                      $ymessage = $ymessage."In this match ".$homeTeam." scored ".$runsForHomeTeam." Runs ".$hitsForHomeTeam." Hits ";
                                      $ymessage = $ymessage." and ".$awayTeam." made ".$runsForAwayTeam." Runs ".$hitsForAwayTeam." Hits";

       


                                  }

       

                                  //print ($ymessage);

       

       

       

                      } // End of If statement

       

                          }
              }
      mysql_close($MyConnection);

       

      $result = "<games><game><baseball>".$ymessage."</baseball></game></games>";

       

      print ($result);
      ?>

       

      ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ---------------------------------

      The data is suppose to be in database