7 Replies Latest reply on Sep 28, 2010 3:11 AM by l33tian

    flex and php connect

    flex_able Level 1

      flex code


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="send_data()">
              import mx.rpc.events.ResultEvent;
              import mx.controls.DataGrid
              private function send_data():void 
              private function handleResult(evt:ResultEvent):void
                  dg1.dataProvider = evt.result.player;
          <mx:Label x="79" y="89" text="username"/>
          <mx:Label x="79" y="128" text="rolnumber"/>
          <mx:TextInput id="nm" x="153" y="87"/>
          <mx:TextInput x="153" y="126" id="roll"/>
          <mx:Button x="127" y="191" label="submit" id="sub" click="send_data()"/>
          <mx:HTTPService id="userRequest" result="handleResult(event)" url="http://localhost/connect.php" useProxy="false" method="POST">
              <mx:request xmlns="">
          <mx:DataGrid id="dg1" x="69" y="261">
                  <mx:DataGridColumn headerText="Name" dataField="name"/>
                  <mx:DataGridColumn headerText="Roll" dataField="roll"/>

      php code


          mysql_connect("localhost", "root", "") or die("cannot connect");
          mysql_select_db("std_db") or die("cannot select database");
          if ($_POST["username"])
              $name = mysql_real_escape_string($_POST["username"]);
              $roll = mysql_real_escape_string($_POST["rollnumber"]);
              $query = "INSERT INTO student (name , roll) VALUES ('$name', '$roll')";
                  echo "sucessfully inserted";
                  echo" error occured";
          $query="SELECT * FROM student";
          $result = mysql_query($query);
          $num_rows = mysql_numrows($result);
          while ($i < $num_rows) 
              $getName = mysql_result($result,$i,"name");
              $getRoll = mysql_result($result,$i,"roll");
              print "<player><name>".$getName."</name><roll>".$getRoll."</roll></player>";




      the application dosent shows any error  bt it dosent add  data into the databasee... i m unable to get it why?