0 Replies Latest reply on Sep 4, 2010 8:55 AM by supernous

    Flex 3 and connection to remote ubuntu server

    supernous

      Good morning,

       

      I'm trying to retrieve the result from a SQL query to populate a datagrid.

       

      My server is a Ubuntu server on a virtual machine. I created the tables I want to extract information from using MySQLWorkbench and put them on my ubuntu server. Flex is running on my Mac.

       

      I have the following code in the mxml file of my Flex project:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="rest_service.send()">
          <mx:HTTPService id="rest_service" url="http://192.168.56.101/testhtml.php"/>
          <mx:DataGrid left="0" right="0" top="0" bottom="0" 
              dataProvider="{rest_service.lastResult.people.person}">
              <mx:columns>
                 <mx:DataGridColumn headerText="Test ID" dataField="userid"/>
                 <mx:DataGridColumn headerText="Name" dataField="username"/> 
                 <mx:DataGridColumn headerText="Email" dataField="emailaddress"/>  
              </mx:columns>
          </mx:DataGrid>
      </mx:Application> 
      

       

       

      The testhtml.php file is on the server (in the /var/www/ folder) and looks like this:

       

      <?php
      
         require ("Connection.php");
      
      $db_handle = mysql_connect($server, $user_name, $password);
      $db_found = mysql_select_db($database, $db_handle);
      
      if ($db_found) {
      
      $Query = "SELECT * from users";
      $Result = mysql_query( $Query );
      
      //print "allo?" . "<br/>";
      
      echo htmlspecialchars('<?xml version="1.0" encoding="utf-8"?>')."<br/>";
      
      echo htmlspecialchars('<people>')."<br/>";
      //print '<people>';
      
      
      // Iterate through the rows, printing XML nodes for each
      while( $Row = mysql_fetch_object( $Result ) )
      {
      
        echo "      ";
        echo htmlspecialchars('<person>') . "<br/>" ;
        echo "            ";
        echo htmlspecialchars('<userid>'.$Row->userid.'') ;
        echo htmlspecialchars('</userid>') . "<br/>";
        echo "            ";
        echo htmlspecialchars('<username>'.$Row->username.'');
        echo htmlspecialchars('</username>') . "<br/>";
        echo "            ";
        echo htmlspecialchars('<emailaddress>'.$Row->emailaddress.'');
        // echo htmlspecialchars('<emailaddress>"'.$Row->emailaddress.'"');
        echo htmlspecialchars('</emailaddress>') . "<br/>";
        echo "      ";
        echo htmlspecialchars('</person>') . "<br/>" ;
      
      }
      echo htmlspecialchars('</people>');
      
      mysql_close($db_handle);
      
      }
      
      else {
      print "Database NOT Found ";
      mysql_close($db_handle);
      }
      
      ?>
      

       

      I tested the php file by typing http://192.168.56.101/testhtml.php in my web browser and I get the xml code expected. The problem is that I don't think Flex is actually connecting to the server.... I have noticed that when you create a new project you can select an application server type but I have no idea what to put for the web root and the root url (I picked php in the list of options for the server type).

      My server is not hosted on my machine but on a virtual machine. Is there something I need to install on my server, and if yes, on which folder?

      Your help would be greatly appreciated. I'm a newbie and have lots to learn and I have been stuck on this for a while now.

      Thank you again,

       

      supernous