4 Replies Latest reply on Apr 25, 2006 11:02 AM by ntsiii

    mx.controls.gridclasses.DataGridColumn is not assignable to Array

    fthj

      mx.controls.gridclasses.DataGridColumn is not assignable to Array

      The error is mx.controls.gridclasses.DataGridColumn is not assignable to Array

      The flex version is Flex 1.5
      Mysql is 5.0

      This an example i have got from the net Flex ,PHP and Mysql, i have made some changes to the php but i have this error in the MXML section i can´t find a solution for it

      the database is called loja
      the table is users
      and the php variable is result
      and user
      the database is in mysql



      mx.controls.gridclasses.DataGridColumn is not assignable to Array
      <mx ataGrid id="dgUserRequest" x="22" y="128" dataProvider="{userRequest.result.users.user}">
      <mx:columns>

      The error is in this line:

      2 Errors found.

      Error /flexandphp/index.mxml:22
      mx.controls.gridclasses.DataGridColumn is not assignable to Array

      <mx ataGridColumn headerText="User ID" dataTipField="userid"/>
      Error /flexandphp/index.mxml:23
      Property may only contain one value
      <mx ataGridColumn headerText="User Name" dataTipField="username"/>
      </mx:columns>
      </mx ataGrid>






      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.macromedia.com/2003/mxml" xmlns="*" creationComplete="userRequest.send()">
      <mx:HTTPService id="userRequest" url=" http://localhost/testes/request.php" useProxy="false" method="POST">
      <mx:request xmlns="">
      <username>{username.text}</username><emailaddress>{emailaddress.text}</emailaddress>
      </mx:request>
      </mx:HTTPService>
      <mx:Form x="22" y="10" width="493">
      <mx:HBox>
      <mx:Label text="Username"/>
      <mx:TextInput id="username"/>
      </mx:HBox>
      <mx:HBox>
      <mx:Label text="Email Address"/>
      <mx:TextInput id="emailaddress"/>
      </mx:HBox>
      <mx:Button label="Submit" click="userRequest.send()"/>
      </mx:Form>

      <mx ataGrid id="dgUserRequest" x="22" y="128" dataProvider="{userRequest.result.users.user}">
      <mx:columns>
      <mx ataGridColumn headerText="User ID" dataTipField="userid"/>
      <mx ataGridColumn headerText="User Name" dataTipField="username"/>
      </mx:columns>
      </mx ataGrid>

      <mx:TextInput x="22" y="292" id="selectedemailaddress" text="{dgUserRequest.selectedItem.emailaddress}"/>
      </mx:Application>



      The error mx.controls.gridclasses.DataGridColumn is not assignable to Array

      the database is called loja
      the table is users
      and the php variable is result
      and user
      the database is in mysql


      mx.controls.gridclasses.DataGridColumn is not assignable to Array
      <mx ataGrid id="dgUserRequest" x="22" y="128" dataProvider="{userRequest.result.users.user}">
      <mx:columns>
      <mx ataGridColumn headerText="User ID" dataTipField="userid"/>
      <mx ataGridColumn headerText="User Name" dataTipField="username"/>
      </mx:columns>
      </mx ataGrid>




      php code file request.php

      <?php


      //connect to the database
      $link = mysql_connect('localhost','root','cacilda');
      if (!$link) {
      die('Could not connect: ' . mysql_error());
      }
      echo 'Connected successfully';

      mysql_select_db('loja');

      // 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) . "'";
      }
      return $value;
      }

      if( $_POST['emailaddress'] AND $_POST['username'])
      {
      //add the user
      $Query = sprintf("INSERT INTO users VALUES ('', '%s', '%s')", quote_smart($_POST['username']), quote_smart($_POST['emailaddress']));

      $Result = mysql_query( $Query );
      }

      //return a list of all the users
      $Query = "SELECT * from users";
      $Result = mysql_query( $Query );

      $Return = "<users>";

      while ( $User = mysql_fetch_object( $Result ) )
      {
      $Return .= "<user><userid>".$User->userid."</userid><username>".$User->username."</username><emailad dress>".$User->emailaddress."</emailaddress></user>";
      }
      $Return .= "</users>";
      mysql_free_result( $Result );
      print ($Return)
      ?>