0 Replies Latest reply on Jun 9, 2008 11:10 AM by chifo

    Problem with flex datchooser and php

    chifo
      Hello Everyone.
      Could anyone help me? I have a problem with datechooser and php app, I'm trying to select a range of date in flex and send that range of date to a php page and create a select clause into de php page with range of dates. but the flex show me an error. This is the error. 1119: Access of possibly undefined property text through a reference with static type mx.controls:DateChooser.
      and this is the flex code:
      <mx:Script>
      <![CDATA[

      // Event handler function to write the selected
      // date to the Label control.
      private function displayDate(date:Date):void {
      if (date == null)
      selection.text = "Date selected: ";
      else
      selection.text = "Date selected: " + date.getFullYear().toString() +
      '/' + (date.getMonth()+1).toString() + '/' + date.getDate();
      }
      ]]>
      </mx:Script>
      <mx:DateFormatter id="df"/>
      <mx:HTTPService id="userRequest" url="https://../../.../phpxml.php" useProxy="false" method="POST">
      <mx:request xmlns="">
      <emailaddress>{emailaddress.text}</emailaddress>
      <initialdate>{fechaInicio.text}</initialdate>
      <enddate>{finFecha.text}</enddate>
      </mx:request>
      </mx:HTTPService>
      <mx:Form x="22" y="10" width="493" height="356">
      <mx:Label text="Email Address"/>
      <mx:TextInput id="emailaddress"/>
      <mx:HBox>
      </mx:HBox>
      <mx:Button label="Submit" click="userRequest.send()"/>
      <mx:HBox horizontalGap="25">
      <mx:VBox>
      <mx:Label text="Fecha inicial de busqueda"/>
      <mx:DateChooser id="dateChooser1" yearNavigationEnabled="true"
      change="displayDate(DateChooser(event.target).selectedDate)"/>
      <mx:Label id="selection" color="blue" text="Date selected:{df.format(dateChooser1.selectedDate)}"/>
      </mx:VBox>

      <mx:VBox>
      <mx:Label text="Fecha final de busqueda"/>
      <mx:DateChooser id="dateChooser2" yearNavigationEnabled="true"
      change="displayDate(DateChooser(event.target).selectedDate)"/>
      <mx:Label id="selection1" color="blue" text="Date selected: {df.format(dateChooser2.selectedDate)}"/>
      </mx:VBox>
      </mx:HBox>
      </mx:Form>





      <mx:DataGrid id="dgUserRequest" x="521" y="10" dataProvider="{userRequest.lastResult.asistencia.user}" width="493" height="356">
      <mx:columns>
      <mx:DataGridColumn headerText="hora" width="100" dataField="hora"/>
      <mx:DataGridColumn headerText="fecha" dataField="fecha"/>
      </mx:columns>
      </mx:DataGrid>

      and the php code is follow:

      $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME,DATABASE_PASSWORD);
      mysql_select_db( DATABASE_NAME );

      // Quote variable to make safe
      function quote_smart($value)
      {
      // Stripslashes
      if (get_magic_quotes_gpc()) {
      $value = stripslashes($value);
      }
      // Quote if not integer
      if (!is_numeric($value)) {
      $value = "'" . mysql_real_escape_string($value) . "'";
      }


      $Query = ("SELECT asistencia.hora, asistencia.fecha, asistencia.i_o, asistencia.llegada
      FROM asistencia, personal WHERE
      personal.usuario_id = asistencia.usuario_id AND
      personal.email = '$_POST[emailaddress]' and
      asistencia.fecha between '$_POST[initialdate]' and '$_POST[endate]'");


      $Result = mysql_query( $Query );

      $Return = "<asistencia>";
      while ( $User = mysql_fetch_object( $Result ) )
      {
      $Return .= "<user><status>".$User->i_o."</status><hora>".$User->hora."</hora><fecha>".$User->fecha." </fecha></user>";
      }

      Thanks and advanced.
      Regards