como leer en flex valores traidos con json

29 views
Skip to first unread message

Alex Gatica91

unread,
Feb 15, 2013, 7:59:47 PM2/15/13
to riac...@googlegroups.com
hola, estoy intentando leer en dos etiquetas los valores que genero en php con json pero me dice que no puede accesar a un null object, adjunto mi código:

aqui esta mi php:

<?php 
include("dbconnect.php");
$table_name="usuarios";
//$idusuario=$_POST['concepto'];
$nick=$_POST['nick'];
$password=$_POST['password'];
//$nivel=$_POST['observaciones'];
//$idpersonal=$_POST['recurso'];

//$sql_con="select * from usuarios  ";
$sql_con="select * from usuarios WHERE nick='".$nick."' AND password='".$password."' ";

$result_con=mysql_query($sql_con);
$data=mysql_fetch_array($result_con);

//

$postUrl=$_SERVER["REQUEST_URI"]; 

if(strpos($postUrl,'storeavalue')){ 
  // Storing a Value
    // Get that tag
  $tag = trim($tag); 
  // Get the value 
  $value = trim($value); 
  

/* 
  // In this example, output to a file, but could use MySQL, or anything
  $myFile = "actividades.txt";
  $fh = fopen($myFile, 'w') or die("can't open file");
  fwrite($fh, str_replace('"', '', $value));
  fclose($fh);

} else { 
  // Retrieving a Value

  $tag = trim($tag);

  $myFile = "actividades.txt";
  $theData=file($myFile);
  fclose($fh);*/

  }


   $resultData = array($data); 

  $resultDataJSON = json_encode($resultData); 

  echo $resultDataJSON; 
 // echo $data;


?> 


y aqui esta mi flex:


mandar_json.method = "POST";
var parameters : Object = new Object();
parameters ["nick"] = nick.text;
parameters ["password"] = password.text;
mandar_json.send(parameters) ;
var dataStr:String = mandar_json.lastResult.toString();
var dataJSONAry:Array = JSON.parse(dataStr) as Array;
json_result.text=dataJSONAry[0].nick;


lo habia puesto en un result de este modo primero:

protected function inserta_bd_local_resultHandler(event:ResultEvent):void
{
// TODO Auto-generated method stub
var inserta_bd_local : HTTPService = new HTTPService();
inserta_bd_local.url = "http://localhost/web/json_usuarios.php";
inserta_bd_local.method = "POST";
var parameters : Object = new Object();
parameters ["nick"] = nick.text;
parameters ["password"] = password.text;
inserta_bd_local.send(parameters) ;
var dataStr:String = event.result.toString();
var dataJSONAry:Array = JSON.parse(dataStr) as Array;
json_result.text=dataJSONAry[0].nick;
}


pero quiero que ese result ocurra en el catch y no puedo mandarlo a llamar como función, espero puedan darme algunas sugerencias


Sergio Brito - yacaFx

unread,
Mar 14, 2013, 7:30:33 PM3/14/13
to riac...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages