1 Reply Latest reply on Jul 28, 2010 10:15 AM by kglad

    Can´t pass variables from PHP to Flash

    miguelvlima

      Hello all,

      I´m having trouble receiving data from my php file using a loadVars   object and sendAndLoad. Every variable is returned as "undefined". Can   somebody help me? I would deeply appreciate it!
      Here´s my actionscript code:

      var retorno:LoadVars = new LoadVars();


      retorno.username = nomeUtilizadorInstancia.text;

      retorno.onLoad = function(ok:Boolean) {
      if(ok) {
      trace(retorno.nome);
      trace(retorno.passwordUser);
      }
      }

      retorno.sendAndLoad("getUserData.php", retorno, 'POST');


      and here´s my php code (works fine when I call it alone, returns   "&passwordUser =7653a183eff0ab32e92b52a93518d56d&nome =Lu?s   Lima&"):




      $username= utf8_decode($_POST['username']);

      //build select statement
      $stmt = oci_parse($conn, "SELECT U.PASSWORD AS PASSWORD, P.NOME AS  NOME FROM UTILIZADORES U INNER JOIN PESSOAS P ON U.PESSOA_ID =                  P.ID WHERE U.NOME_UTILIZADOR = $username");

      oci_execute($stmt);

      $dados = ''; // Variável responsável por armazenar o resultado a cada loop.

      while($n = oci_fetch_array($stmt)){
      $dados .= '&passwordUser =' . $n['PASSWORD'];
      $dados .= '&nome =' . $n['NOME'];
      };


      echo
      utf8_encode($dados) . "&";



      Thank you very much!