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????
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.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"
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????
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
ASKER
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
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?
echo($myParam);
output?
ASKER
my $myParam =AbrahamJohnClinton
thats the echo what i get .
thats the echo what i get .
ASKER
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??????
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);
echo("&namestr=" . $myParam . "&");
what does it trace in flash?
trace(this.namestr);
ASKER
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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("|");
}
}
==========================