Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-20-2007, 06:51 PM   #1
bdrshcla
Registered User
 
Join Date: Jul 2007
Posts: 2
Exclamation sendAndLoad returning entire PHP file as one giant string

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:
Code:
 loadphp = function(){
	
	var phpfile:String = 'parser3.php';
	
	var send_obj:LoadVars = new LoadVars();
	var return_obj:LoadVars = new LoadVars();
	

	
	send_obj.sendAndLoad("parser3.php",return_obj,'POST');
	
	return_obj.onLoad = function(success){
		if(success){
			trace ("countString="+this.countString);
			
			count=this.countString;
			_root.countArray=count.split("&");
			profname=this.nameString;
			_root.nameArray=profname.split("&");
			rating=this.ratingString;
			_root.ratingArray=rating.split("&");
			votes=this.votesString;
			_root.votesArray=votes.split("&");
		}else{
			trace('failed');
		}
	}
	
	
	
}
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!
bdrshcla is offline   Reply With Quote
Old 07-20-2007, 07:00 PM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

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...
ActionScript Code:
send_obj.sendAndLoad("http://localhost/project/parser3.php",return_obj,'POST');
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 07-21-2007, 02:56 AM   #3
bdrshcla
Registered User
 
Join Date: Jul 2007
Posts: 2
Default

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!
bdrshcla is offline   Reply With Quote
Old 07-21-2007, 02:27 PM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

You nailed it correctly...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
flash file not shown in php file Manou Other Flash General Questions 0 02-18-2007 01:25 AM
LoadVars sendAndLoad xml php edacsac ActionScript 2.0 1 01-08-2007 05:15 PM
sendAndLoad with PHP bug? Flash 6 works, Flash 7 fails dwagner ActionScript 1.0 (and below) 3 09-26-2005 05:19 PM
Testing Flash sendAndLoad php file mvhall Server-Side Scripting 3 08-25-2005 03:56 PM
Save XML file Locally via PHP? MDiddy Server-Side Scripting 1 08-05-2005 04:13 AM


All times are GMT. The time now is 06:22 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.