Link to home
Start Free TrialLog in
Avatar of VBpassion
VBpassion

asked on

Get result from PHP--HOW???? sendAndLoad

Hi experts, i have a very simple problem, as im new to this so i don't know. Well the thing is, i have flash interface and i have mysqlDB and php. Im calling a php and get the results from the mysql. This is perfect, till here everything works. but now once the result is fetched from the php, how to pass it to Flash, the result is STRING.

my flash code is below :

var c = new LoadVars();
c.namestr = "";  //this is the empty parameter im passing to PHP
c.sendAndLoad("index.php", c, "post");
c.onLoad = showContent;
function showContent(success) {
      if (success) {
            //
            ??
            what should i write here??
            how to get the result string what PHP has got from.
            //
      }
}


AND THE CODE FOR INDEX.PHP IS BELOW: (WORKS PERFECT AND I SEEN THE REsULT)

<?

//--------this is to connect to mysql
$dbcnx = @mysql_connect("localhost", "admin", "mohsin");
if (!$dbcnx) {  echo( "<P>Unable to connect to the database server at this time.</P>" );
      exit();
}

//---------this is to select my Database
mysql_select_db("test", $dbcnx);
if (! @mysql_select_db("test") ) {
        echo( "<P>Unable to locate the table at this time.</P>" );
exit();
}

//-----this is the parameter im passing from flash, im not sure if this line is required or not
$myParam = $HTTP_POST_VARS['namestr'];

//--------here Im writing the select query
$result = mysql_query("SELECT name FROM test");

 //-------this variable will hold the result STRING.
$str="";

while ( $row = mysql_fetch_array($result) ) {
      $str=$str.$row["name"];
      }
      $myParam=$str;   // THIS IS THE RESULT STRING, TO BE PASSED TO FLASH
      echo($myParam);
      //or should it be  echo("namestr=".$myParam);
?>

SO NOW PLEASE TELL ME HOW TO PASS THE RESULT STRING TO FLASH...hOW????
Avatar of negatyve
negatyve

====================================
echo("namestr=".$myParam);
// echo("namestr=".$str);

and in flash

function showContent(success) {
     if (success) {
         trace(this.namestr);
     }
}
====================================
you can get the array back to flash with:
====================================
while ( $row = mysql_fetch_array($result) )
{
     $str=$str . "|" .$row["name"];
}

and in flash

function showContent(success) {
     if (success) {
         var names_array = this.namestr.split("|");
     }
}
====================================
Avatar of VBpassion

ASKER

hi man , nothing works........i did exactly the same as u told...but when i trace in flash, nothing comes..i can't see my result string....pzl tell me
i ried to check if the sucess is true or not , and it comes...

function showContent(success) {
      trace("hi");
      if (success) {
            trace(this.namestr);
      }
}

the trace shows "HI"....but not this.namestr......why???. Please get this thing done, as this is the only small hitch stopping me from my project's progress....plz help
what does your

echo($myParam);

output?
my $myParam =AbrahamJohnClinton
thats the echo what i get .
my query returns 3 rows, Abraham , john, clinton.

and then I do

while ( $row = mysql_fetch_array($result) ) {
     $str=$str.$row["name"];
     }
     $myParam=$str;   // THIS IS THE RESULT STRING, TO BE PASSED TO FLASH
     echo($myParam);

SO echo($myParam) = AbrahamJohnClinton

so when it shows me, why in the flash im not able to trace it ...why??????
ok, so if you use:

echo("&namestr=" . $myParam . "&");

what does it trace in flash?

 trace(this.namestr);
hi dude.......ok i did wat u asked me to

here is the trace of
     echo("&namestr=" . $myParam . "&");      

      ".$myParam."

this is the trace, exactly...with quotes. The trace in flash shows me the above line including quotes.

i guess now it shouldn't be difficult for u pal...plz tell me what is it.?? whats the problem



ASKER CERTIFIED SOLUTION
Avatar of negatyve
negatyve

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial