sendAndLoad: vars fr PHP to Flash not being interpreted

Hi,

I’m Cesar and I am new here and after several hours of trying to resolve this problem, I have joined Kirupa forum to see if I can find any help. Without much ado, here is my dilema…

I have a simple script in flash CS3 (9 AS 2.0) that sends variables to a php5 script and then accepts the response from the php5 script and places those vars into text fields.

what my problem is that when flash accepts those variables, from php5, it literally takes what is passed. that is in my php5 script I have:

print “&rMonth=$rMonth&”;

when displaying in flash, the “dynamic text” field shows: “$rMonth”.
if I replace $rMonth with “How Are You”, I see “How Are You”.

when I run the php5 script in a cmd shell, the values are displayed correctly. $rMonth displays “06”.

I am running this project locally on my computer.
I have installed apache, with MySQL db (where I am getting the values from). Flash 9 with AS 2.0. Php5.0.

just for show, here is the flash script, with some editing of course:


function getTipofMonthData(Mn, Yr) {

// create empty movie clips to temporarily send and hold values from the php script
var send_lv:LoadVars = new LoadVars();
var receive_lv:LoadVars = new LoadVars();

// on success of the load of variables do the following.
// all text fields are 'dynamic text' fields - error handling was removed
receive_lv.onLoad = function(success:Boolean) {
     month_txt.text = receive_lv.rMonth;
     headline_txt.text = receive_lv.headline;
     paragraph_mc.paragraph_txt.text = receive_lv.paragraph
     signature_txt.text = receive_lv.signature;
     firstMonth = receive_lv.firstMo;
     firstYear = receive_lv.firstYr;    
 }

//variables to send to the php script to get results.
send_lv.mV = Mn;
send_lv.yV = Yr;
send_lv.sendAndLoad("phpScriptHere.php5", receive_lv, "POST");

here is the php script - edited.

print “&rMonth=$rMonth&headline=$headline&paragraph=$para&signature=$signature&firstMo=$firstMo&firstYr=$firstYr&”;

Any help would be appreciated…

Thank You Very Much (in advance)…

Maybe when you echo try:


echo "&rMonth=".$rMonth."&";

?

Thanks for the response “project107”, but I have tried several variations to posting information back to Flash.

echo “&rMonth=”.$rMonth."&";
print “&rMonth=”.$rMonth."&";

even with:

$toFlash = “&rMonth=”;
$toFlash .= $rMonth;

[echo/print] $toFlash;

what happens is that the literal translation of $rMonth is applied to the dynamic text field. I don’t get the actual value that is stored in $rMonth.

I was wondering if there is a bug or something in Flash CS3 with PHP5.0 or something, or perhaps another way of doing this.

Maybe I should just start from scratch. Starting fresh can sometimes trigger an idea.

Thank You Again and please post any additional information you may have.

I found the problem!..

You cannot test the sendLoadVars function locally (directly in FLASH). You have to load the files onto a webserver and test. I was accessing the files directly thru the “CTRL+ENTER” function which will not work.

when I viewed the actual swf in a browser, the swf communicated with the php5 script correctly, the script accessed my local db and returned values to flash correctly.