Variable Flash -> php -> mysql -> php -> flash P

  • needflashelp
  • Born
  • Born
  • needflashelp
  • Posts: 4

Post 3+ Months Ago

:? Please some 1 canhelp me? .. I have this probles

this the source:
b1.onRelease = function() {
vc1 = c1.getValue(); //combobox
vc2 = c2.getValue(); //combobox
vt1 = t1.getValue(); //text imput
vt2 = t2.getValue(); //textimput
}

I need sen vt1 and vc1 to php to ask a table called "calles" and need compare from the table idcbox with the value of vt1 and numero with the value of vc1 and need back the rows "cx" and "cy" from the same table and that values need to be send to 2 variables in flash to can work with that in the source....

I try all that of loadandsend put cant make it works

PLEASE HELP!!!!![/b]
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

the actionscript will be something like:
Code: [ Select ]
var lv = new LoadVars();
lv.vc1 = c1.getValue();
lv.vc2 = c2.getValue();
lv.vt1 = t1.getValue();
lv.vt2 = t2.getValue();

lv.onLoad = function(success)
{
    trace(lv.cx);
    trace(lv.cy);
}

lv.sendAndLoad("savedata.php", "_blank", "_POST");
stop();
  1. var lv = new LoadVars();
  2. lv.vc1 = c1.getValue();
  3. lv.vc2 = c2.getValue();
  4. lv.vt1 = t1.getValue();
  5. lv.vt2 = t2.getValue();
  6. lv.onLoad = function(success)
  7. {
  8.     trace(lv.cx);
  9.     trace(lv.cy);
  10. }
  11. lv.sendAndLoad("savedata.php", "_blank", "_POST");
  12. stop();


and the savedata.php will be:
Code: [ Select ]
<?
$vc1 = $_POST["vc1"];
$vc2 = $_POST["vc2"];
$vt1 = $_POST["vt1"];
$vt2 = $_POST["vt2"];

// use this data to get data from database, and to retrive $cx and $cy

$outputVars = "cx=".$cx."&cy=".$cy;
echo $outputVars;
?>
  1. <?
  2. $vc1 = $_POST["vc1"];
  3. $vc2 = $_POST["vc2"];
  4. $vt1 = $_POST["vt1"];
  5. $vt2 = $_POST["vt2"];
  6. // use this data to get data from database, and to retrive $cx and $cy
  7. $outputVars = "cx=".$cx."&cy=".$cy;
  8. echo $outputVars;
  9. ?>
  • needflashelp
  • Born
  • Born
  • needflashelp
  • Posts: 4

Post 3+ Months Ago

Hi, thanks IceCold by the help ... I cant yet make this think work can you see if there is something wrong on code? please?

b1.onRelease = function() {
var lv = new LoadVars();

lv.vc1 = c1.getValue();
lv.vc2 = c2.getValue();
lv.vt1 = t1.getValue();
lv.vt2 = t2.getValue();
lv.onLoad = function(success){
trace(lv.cx);
trace(lv.cy);
}
lv.sendAndLoad("buscar.php", "_blank", "_POST");
stop();

t2=cx; // t2 is the value of a textimput that I use to see if values are right but get the message "undefined"
}

**** how must be received the values on flash and where? ******



PHP:

<?
$host = "localhost"; // el host de la base de datos
$user = "root"; // usuario de la base de datos
$pass = ""; // contraseƱa de la base de datos
$bd = "geo"; // base de datos a usar

$conexion = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($bd,$conexion) or die(mysql_error());

$vc1 = $_POST["vc1"];
$vc2 = $_POST["vc2"];
$vt1 = $_POST["vt1"];
$vt2 = $_POST["vt2"];

$q = "SELECT cx,cy from `calles` where idcbox='$vc1' and numero='$vt1'";
$r = mysql_query($q, $bd);

$outputVars = "cx=".$cx."&cy=".$cy;
echo $outputVars;


?>

}
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

flash code ( dont use a local variable outside of the function):
Code: [ Select ]
var lv = new LoadVars();
lv.onLoad = function(success){
t2=lv.cx;
}

b1.onRelease = function() {
lv.vc1 = c1.getValue();
lv.vc2 = c2.getValue();
lv.vt1 = t1.getValue();
lv.vt2 = t2.getValue();
lv.sendAndLoad("buscar.php", "_blank", "_POST");
}
stop();
  1. var lv = new LoadVars();
  2. lv.onLoad = function(success){
  3. t2=lv.cx;
  4. }
  5. b1.onRelease = function() {
  6. lv.vc1 = c1.getValue();
  7. lv.vc2 = c2.getValue();
  8. lv.vt1 = t1.getValue();
  9. lv.vt2 = t2.getValue();
  10. lv.sendAndLoad("buscar.php", "_blank", "_POST");
  11. }
  12. stop();

i dont know if the php code when reading the values from database is ok, but u can test it and fix it if necessary.
As for a test of the flash file, you can hardcode the values for $cx and $cy in the php file (do this only to make sure the flash is ok, if you know the values are read ok from database, no need to do it):
Code: [ Select ]
$cx = 5;
$cy = 7;
$outputVars = "cx=".$cx."&cy=".$cy;
  1. $cx = 5;
  2. $cy = 7;
  3. $outputVars = "cx=".$cx."&cy=".$cy;
  • needflashelp
  • Born
  • Born
  • needflashelp
  • Posts: 4

Post 3+ Months Ago

Dont work, some one knows how can I do that?

(im working on flash 8)
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

well, then, if that is your choice, so be it
  • needflashelp
  • Born
  • Born
  • needflashelp
  • Posts: 4

Post 3+ Months Ago

this is the code but send the message "undefined" what can be?


************************** flash *****************************
b1.onRelease = function(){
var cargar_lv:LoadVars = new LoadVars()
cargar_lv.vc1 = c1.getValue()
cargar_lv.vt1 = t1.getValue()
cargar_lv.sendAndLoad("buscar.php",cargar_lv,"post")
cargar_lv.onLoad = function(){
t2 = cargar_lv.cx;
t3 = cargar_lv.cy;
}
}

***************************** php **************************
<?
$host = "localhost"; // el host de la base de datos
$user = "root"; // usuario de la base de datos
$pass = ""; // contraseƱa de la base de datos
$bbdd = "geo"; // base de datos a usar


$conexio = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($bbdd,$conexio) or die(mysql_error());




$vc1 = $_POST["vc1"];
$vt1 = $_POST["vt1"];


$consulta = "SELECT cx,cy, metros FROM calles where idcbox='$vc1' and numero='$vt1'";
$res = mysql_query($consulta,$bbdd)or die(mysql_error());

******* // here should be the part that I need to rescue tha values from mysql and putit on $cx $cy ///**********



$outputVars = "cx=".$cx."&cy=".$cy;
echo $outputVars;



?>

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.