View Full Version : sendAndLoad returning entire PHP file as one giant string

07-20-2007, 06:51 PM
Hello, I have a strange problem in that when I try to send variables from my PHP script back to a return object in Flash, the return object does not acquire what I specified on the PRINT line in the PHP, but rather it seems to parse the entire length of the PHP code into properties. For instance, if I have a line at the beginning of my PHP code that is $errmsg = 'Cannot connect' then according to the Flash debugger, my return object gains its own property called $errmsg which is equal to a string of 'Cannot connect.' It also gains properties for anything else in my PHP code that follows an equal sign.

Now, I'm very new to PHP and getting it to work with Flash, but I have gotten results a few times in the past with it, and I was under the impression that in order to send variables back to Flash you simply write them on a PRINT line in the PHP. I have no idea why Flash is receiving the entire length of my PHP code as though I had written PRINT before everything. What makes me believe this is a problem with my actionscript is that it does the same thing when I use instead use PHP files that have worked correctly in the past. Also, my PHP file prints what it should when I call it in the browser.

Here is my function which calls the PHP:
loadphp = function(){

var phpfile:String = 'parser3.php';

var send_obj:LoadVars = new LoadVars();
var return_obj:LoadVars = new LoadVars();


return_obj.onLoad = function(success){
trace ("countString="+this.countString);


Since Flash is parsing the entire PHP file in a bizarre manner, all of the properties I had actually specified to the return object come up as undefined. I just need to know how to get Flash to only receive the PRINT line from my PHP file and nothing more.

This is really confusing me, so hopefully there's a simple fix out there someone is aware of. Thanks so much for any help you can offer!

07-20-2007, 07:00 PM
Howdy and Welcome... :)

I believe this is the case where you are testing the SWF within the Flash IDE that is not rendering the PHP script properly...
Try providing the full path to the PHP scirpt and see if that works... I'll provide you more information if that works...

07-21-2007, 02:56 AM
Thanks! That seemed to do the trick. I guess that makes some sense that without specifying the full path, the PHP wasn't running through the server and Flash was just interpreting it as a text file. Thanks so much again, I probably would never have figured that out on my own!

07-21-2007, 02:27 PM
You nailed it correctly... ;)