Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/05/2009, 20:42
hIUG
 
Fecha de Ingreso: abril-2009
Mensajes: 18
Antigüedad: 15 años, 1 mes
Puntos: 0
Insersión de registros en una BD desde Flex con PHP

Hola a todos!!

Desarrolle una aplicación para dar de alta registros desde Flex con PHP y HTTPservice, el código MXML es el siguiente:

Código javascript:
Ver original
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="adobe.com/2006/mxml" layout="absolute">
  3.  
  4. <mx:Script>
  5.     <![CDATA[
  6.        
  7.         import mx.controls.Alert;
  8.         import mx.rpc.events.FaultEvent;
  9.         import mx.rpc.events.ResultEvent;
  10.         import mx.rpc.http.HTTPService;
  11.        
  12.         private function resutadoI():void
  13.         {
  14.             if(insertar.lastResult.okok == "sisisi")
  15.             {
  16.                 Alert.show("Ok, todo bien, ya se inserto");
  17.             }
  18.             else
  19.             {
  20.                 if(insertar.lastResult.okok == "nononono")
  21.                 {
  22.                     Alert.show("No se regsistro");
  23.                 }
  24.             }
  25.            
  26.             if(insertar.lastResult.okok == "blabla")
  27.             {
  28.                 Alert.show("Prueba");
  29.             }
  30.         }
  31.        
  32.         private function faultHandler(event:FaultEvent):void
  33.         {
  34.             Alert.show(event.fault.faultDetail, "Error");
  35.         }
  36.        
  37.     ]]>
  38. </mx:Script>
  39.  
  40.     <mx:HTTPService id="insertar" result="resutadoI()" fault="faultHandler(event)" url="127.0.0.1/ACDA/ACDA-debug/inscribeP.php" showBusyCursor="true" method="POST" useProxy="false">
  41.     <mx:request xmlns="">
  42.         <personap>
  43.             {a.text}
  44.         </personap>
  45.         <cursop>
  46.             {b.text}
  47.         </cursop>
  48.         <categoriap>
  49.             {c.text}
  50.         </categoriap>
  51.         <correop>
  52.             {d.text}           
  53.         </correop>
  54.     </mx:request>
  55.    </mx:HTTPService>
  56.  
  57.     <mx:Button x="10" y="10" label="Insertar Registro" width="869" height="490" fontSize="13" fontStyle="italic" click="insertar.send()"/>
  58.     <mx:Label x="925" y="36" id="a" text="adklfjjsfl"/>
  59.     <mx:Label x="925" y="36" id="b" text="asdklfjk aewhuiofw e"/>
  60.     <mx:Label x="925" y="36" id="c" text="oweiuo asdfa wefh w hfsh do "/>
  61.     <mx:Label x="925" y="36" id="d" text="1"/>
  62.    
  63. </mx:Application>

Y el código PHP (inscribeP.php) es:

Código PHP:
<?php

define
"DATABASE_SERVER""localhost" );
define"DATABASE_USERNAME""root" );
define"DATABASE_PASSWORD""pass" );
define"DATABASE_NAME""acda" );

$link mysql_connect(DATABASE_SERVERDATABASE_USERNAMEDATABASE_PASSWORD) or die(mysql_error());

mysql_select_dbDATABASE_NAME );

$personap $_POST['personap'];
$cursop $_POST['cursop'];
$categoriap $_POST['categoriap'];
$correop $_POST['correop'];

$insertar mysql_query(”INSERT INTO incritos (personacursocategoriaactivoVALUES ({$personap}{$cursop}{$categoriap}1)$link);

print 
"<okok>\n";

if (!
$insertar
{
    print 
"nononono";
}

else
{
    print 
"sisisi";
}

print 
"blabla";

print 
"\n</okok>";
?>
No se si alguien pueda ayudarme a solucionar el problema, no creo que sea tan complicado pero la verdad ya me quede estancado

Y de hecho no saca ninguno de los tres mensajes de alerta que deben salir

Gracias