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

    flex request not finding php data member

    3rdshiftcoder


      hi-
      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.

      <?php

      class weather
      {
      public $mydata;
      }

      try {
      $shared=false;
      ini_set('include_path',ini_get('include_path').':/home/third/public_html/includes/');

      if ($shared) {
      include("/home/third/public_html/includes/dbMyLimitInclude.php");

      } else {
      include "dbMyLimitInclude.php";
      }

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

      //var_dump($client->__getProperties());


      $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,
      //"qpf"=>false,"pop12"=>false,"snow"=>false,"dew"=>false,"wspd"=>false,
      //"wdir"=>false,"sky"=>false,"wx"=>false,"waveh"=>false,"icons"=>false,
      //"rh"=>false,"appt"=>false,"incw34"=>false,"incw50"=>false,
      //"incw64"=>false,"cumw34"=>false,"cumw50"=>false,"cumw64"=>false,
      //"conhazo"=>false,"ptornado"=>false,"phail"=>false,"ptstmwinds"=>false,
      //"pxtornado"=>false,"pxhail"=>false,"pxtstmwinds"=>false,"ptotsvrtstm"=>false,
      //"pxtotsvrtstm"=>false,"wgust"=>false);

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

      default:
      $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);
      list($startDate)=mysql_fetch_row($sel_result);

      //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
      $a1=eregi("<value>(.*)</value>",$xml2,$regs);


      //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\">",
      "</go>",$r);
      $i = strrpos($r,"</go>"); //get start position
      $r = substr_replace($r,"",$i+5); // truncate end of file after </go>

      //fwrite($fp,$r);
      //fclose($fp);


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

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

      }

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

      for($i = 0; $i<10;$i++){
      $tFld[$i]=$temp[$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
      if(mysql_num_rows($sel_result)>0){
      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";


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

      $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 "";
      else{
      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);

      mysql_close();


      }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"
          viewSourceURL="/localhost/flexForecast.swf">
          <mx:Script>
          <![CDATA[
          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:Script>
          <mx:HTTPService id="weatherRequest" url="/t1.php"
          useProxy="false" method="GET" resultFormat="text"
          result="weatherJSON(event)">
          <mx:request xmlns="">
          <zip>{zip.value}</zip>
          <getWeather>"true"</getWeather>
          </mx:request>
          </mx:HTTPService>

          <mx:Panel x="10" y="10" width="350" height="200" title="Rate Customer
          Service">
          <mx:ComboBox id="zip" x="20" y="20" width="100">
          <mx:dataProvider>
          <mx:Array>
          <mx:String>13617</mx:String>
          <mx:String>85044</mx:String>
          <mx:String>05401</mx:String>
          <mx:String>76180</mx:String>
          <mx:String>90810</mx:String>
          <mx:String>59403</mx:String>
          <mx:String>80210</mx:String>
          <mx:String>02139</mx:String>
          <mx:String>18080</mx:String>
          <mx:String>25313</mx:String>
          <mx:String>04105</mx:String>
          </mx:Array>
          </mx:dataProvider>
          </mx:ComboBox>
          <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:columns>

          <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"/>

          </mx:columns>
          </mx:DataGrid>

          </mx:Panel>
          </mx:Application>
          • 2. Re: flex request not finding php data member
            3rdshiftcoder Level 1
            and of course:
            thanks for any help or advice!
            jim
            • 3. Re: flex request not finding php data member
              3rdshiftcoder Level 1
              Hi-
              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,
              jim