3 Replies Latest reply on Oct 1, 2007 11:27 PM by 3rdshiftcoder

    flex request not finding php data member


      i get this error ReferenceError: Error #1069: Property mydata not found on Number and there is no default value.
      at weatherInput/weatherInput::weatherJSON()[C:\a1\flexForecast\weatherInput.mxml:15]
      at weatherInput/__weatherRequest_result()[C:\a1\flexForecast\weatherInput.mxml:25]

      when i click on the button after selecting a zip code it acts like the request goes through to php and somehow
      it is not seeing the object or data it contains.
      i am going to post my php code which compiles below and my flex code with action script embeded in the next post.
      if someone would glance at it and if it jumped off the page give me a hint or heads up as to what i did wrong i'd really
      appreciate it. i am taking data from the government weather server and i want it to end up in a grid on my flex form.
      i dont know if has anything to do with it but i put the .swf file in my php web servers "public" directory and that error msg
      is referring to the flex project directory which is different from the servers public directory.


      class weather
      public $mydata;

      try {

      if ($shared) {

      } else {
      include "dbMyLimitInclude.php";

      $ws = " http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl";
      $client = new SoapClient($ws,array('trace'=>1));


      $zip = $_GET['zip'];
      echo $zip + " zipppppp";
      $format = "24 hourly";

      $numDays = 5;

      //$product = "time-series";
      //$startTime = "2007-09-23T00:00";
      //$endTime = "2007-09-23T04:00";
      //$weatherParameters= array("maxt"=>false,"mint"=>false,"temp"=>true,

      case '13617':
      $latitude = 44.58;
      $longitude = -75.19;
      case '85044':
      $latitude = 33.53;
      $longitude = -112.08;
      case '05401':
      $latitude = 44.47;
      $longitude = -73.20;
      case '76180':
      $latitude = 32.77;
      $longitude = -97.31;
      case '90810':
      $latitude = 33.80;
      $longitude = -118.19;
      case '59403':
      $latitude = 47.50;
      $longitude = -111.31;
      case '80210':
      $latitude = 39.74;
      $longitude = -104.98;
      case '02139':
      $latitude = 42.37;
      $longitude = -71.1;
      case '18080':
      $latitude = 40.75;
      $longitude = -75.61;
      case '25313':
      $latitude = 36.83;
      $longitude = -76.30;
      case '04105':
      $latitude = 43.66;
      $longitude = -70.24;

      $latitude = 0.00;
      $longitude = 0.00;
      } // switch

      $link1ID = @mysql_connect("$host","$user","$paswd","$db")or die("could not connect1");
      @mysql_select_db("kb")or die("could not select the database");
      $sel_date = "SELECT NOW() AS d1";
      $sel_result = mysql_query($sel_date);

      //echo $client->NDFDgen($latitude,$longitude,$product,$startTime,$endTime,$weatherParameters);

      //$fp = fopen("c:\\php\includes\junk.xml", "w+") or die("Couldn't open file");
      $xml2 = $client->NDFDgenByDay($latitude,$longitude,$startDate,$numDays,$format);

      //give me any tag that is value with a string in the middle

      //put the xml header on and fix up the format of the file so it is simplexml
      $r = '<'.'?'.'x'.'m'.'l vers'.'ion="1'.'.'.'0'.'" standalone'.'='.'"yes"'.'?'.'>'."\n";
      $r = $r.'<'."go".'>'."\n".'<'."temperature".'>'."\n".$regs[0]."\n".'<'.'/weather-conditions'.' >' ;
      //echo $regs[1];

      // this next section kills the attributes so that just the tag is left
      $r = str_replace("type='minimum'","",$r);
      $r = str_replace("units=\"Fahrenheit\"","",$r);
      $r = str_replace("time-layout=\"k-p24h-n5-1\"","",$r);
      $r = str_replace("<temperature >","<temperature>",$r);
      $r = str_replace("<probability-of-precipitation type='12 hour' units=\"percent\" time-layout=\"k-p12h-n10-2\">",
      $i = strrpos($r,"</go>"); //get start position
      $r = substr_replace($r,"",$i+5); // truncate end of file after </go>


      //$xml3 = simplexml_load_file("c:\php\includes\junk.xml");
      $xml3 = simplexml_load_string($r);

      $temp = array();
      for($i = 0;$i<2;$i++){
      foreach($xml3->temperature[$i]->children() as $v)
      $temp[$num] = $v;


      $tFld = array("max1","max2","max3","max4","max5","min1","min2","min3","min4","min5");

      for($i = 0; $i<10;$i++){
      echo "$tFld[$i]";


      // date
      // max1, max2
      // zip

      //connect to the server and select the database
      $link1ID = @mysql_connect("$host","$user","$paswd","$db")or die("could not connect1");
      @mysql_select_db("kb")or die("could not select the database");
      $sel_date = "SELECT NOW() AS d1";
      $sel_result = mysql_query($sel_query);
      $startDate = mysql_num_rows($sel_result,0,"d1");

      $sel_query = "SELECT * FROM w_max where w_max.zip = '$zip' AND w_max.startDate = '$startDate'";
      $sel_result = mysql_query($sel_query);

      //data for that forecast is in DB - display it
      while(list($tFld[0],$tFld[1],$tFld[2],$tFld[3],$tFld[4],$tFld[5],$tFld[6],$tFld[7],$tFld[ 8],$tFld[9])=mysql_fetch_row($sel_result)){
      echo "'data found '.'max1 is'.$max1";


      $w = new weather();

      $w->mydata = $tFld;
      echo json_encode($w);

      } // while

      //data not found in the DB - insert it
      }else {

      //connect to the server and select the database
      $linkID2 = @mysql_connect("$host","$user","$paswd","$db")or die("could not connect2");
      @mysql_select_db("kb")or die("could not select the database");
      $query = "INSERT INTO w_max set zip = '$zip', startDate = '$startDate', max1 = '$tFld[0]',
      max2 = '$tFld[1]', max3 = '$tFld[2]', max4 = '$tFld[3]', max5 ='$tFld[4]',
      min1 = '$tFld[5]', min2 = '$tFld[6]', min3 = '$tFld[7]', min4 = '$tFld[8]', min5 ='$tFld[9]'";
      $result = mysql_query($query);

      if($result) echo "";
      echo "<p>weather data not inserted</p>";

      // delete data for all zips prior to todays date
      $linkID3 = @mysql_connect("$host","$user","$paswd","$db")or die("could not connect3");
      @mysql_select_db("kb")or die("could not select the database");
      $del_qry = "delete from w_max where TO_DAYS(NOW())-TO_DAYS(startDate)>1";
      $del_result = mysql_query($del_qry);


      }catch(Exception $e){
      echo $e->getMessage();

        • 1. Re: flex request not finding php data member
          3rdshiftcoder Level 1
          :PART 2 of source code from other post in this thread:

          <?xml version="1.0" ?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          import mx.collections.ArrayCollection;
          import mx.rpc.events.ResultEvent;
          import com.adobe.serialization.json.JSON;

          private function weatherJSON(event:ResultEvent):void
          //get the raw JSON data and cast to String
          var rawData:String = String(event.result);
          var weather:Object = JSON.decode(rawData);
          var temperatures:Array = weather.mydata as Array;

          //Data Grid Code
          var weatherCollection:ArrayCollection = new ArrayCollection(temperatures);
          dgWeather.dataProvider = weatherCollection;
          <mx:HTTPService id="weatherRequest" url="/t1.php"
          useProxy="false" method="GET" resultFormat="text"
          <mx:request xmlns="">

          <mx:Panel x="10" y="10" width="350" height="200" title="Rate Customer
          <mx:ComboBox id="zip" x="20" y="20" width="100">
          <mx:Button x="140" y="20" label="Send" click="weatherRequest.send();"/>
          <mx:Label x="20" y="120" text="{zip.value}"/>
          <mx:DataGrid x="10" y="174" width="460" enabled="true"
          editable="false" id="dgWeather">

          <mx:DataGridColumn headerText="maxTemp1" dataField="max1"/>
          <mx:DataGridColumn headerText="maxTemp2" dataField="max2"/>
          <mx:DataGridColumn headerText="maxTemp3" dataField="max3"/>
          <mx:DataGridColumn headerText="maxTemp4" dataField="max4"/>
          <mx:DataGridColumn headerText="maxTemp5" dataField="max5"/>

          <mx:DataGridColumn headerText="minTemp1" dataField="min1"/>
          <mx:DataGridColumn headerText="minTemp2" dataField="min2"/>
          <mx:DataGridColumn headerText="minTemp3" dataField="min3"/>
          <mx:DataGridColumn headerText="minTemp4" dataField="min4"/>
          <mx:DataGridColumn headerText="minTemp5" dataField="min5"/>


          • 2. Re: flex request not finding php data member
            3rdshiftcoder Level 1
            and of course:
            thanks for any help or advice!
            • 3. Re: flex request not finding php data member
              3rdshiftcoder Level 1
              i decided to back track and try a simpler example.
              i noticed that get wouldnt work on an author's example.
              so i will try again tomorrow with post.
              i can't remember if there is any special thing or setting i have to do with get in php.

              sorry for the confustion. i hope tomorrow it will be behind me.
              have a nice week,