Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-30-2004, 01:10 PM   #1
nikkelei
Registered User
 
Join Date: Aug 2003
Posts: 9
Default Passing variable to PHP + back to flash

Ok, can anybody help out with this? Basic setup; all I want to do is sending a variable to PHP and getting it sent back to Flash

My actionscript looks like this:
PHP Code:
loadVarsText = new loadVars();
loadVarsText.gosub="synergi";
loadVarsText.onLoad = function(success) {
    if (
success) {
        
trace("done loading");
    } else {
        
trace("not loaded");
    }
};

loadVarsText.sendAndLoad ("text.php"gosub"POST"); 
The PHP part looks like this:
PHP Code:
<?php
$gosub 
$_POST['gosub'];
echo 
"&text=".urlencode($gosub);
?>
If I just use .load and set the variable in the php - no problem, but if I use .sendAndLoad i don't get anything back ?
Regs,
Nico

Last edited by CyanBlue; 05-31-2004 at 12:02 PM. Reason: PHP tag is applied...
nikkelei is offline   Reply With Quote
Old 05-30-2004, 03:29 PM   #2
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default

Code:
myVars = new LoadVars();
myVars.checklog = checklog;
myVars.onLoad = function (checkPlease)
{
	if(checkPlease == true)
		{
		        if(myVars.checklog == "1")
				{
				//allowPost
				}
                }
}
myVars.sendAndLoad("secretArea.php", myVars, "POST");
PHP Code:
if($count 0)
{
    print 
$rString."&checklog=1";
        

else
{
    print 
$rString."&checklog=0";
        
}

?> 
This is a very basic piece of code that i use to check whether or not a username exists in the database, if it does (i.e., checklog = 1) then i allow a post.

Regards, Snapple

Last edited by snapple; 05-30-2004 at 03:34 PM.
snapple is offline   Reply With Quote
Old 05-30-2004, 05:29 PM   #3
nikkelei
Registered User
 
Join Date: Aug 2003
Posts: 9
Default

Ah that did it. Thanks snapple.....

NEXT PROBLEM!!!

My variables load just fine now. But a new problem has emerged. When I get it into Flash all the danish characters dissaper, and some odd letters are added instead. They display fine in the database so I assume that the problem lies within the PHP script....

The PHP looks like this now:
PHP Code:
<?php
$linkID
mysql_connect("xxx","xxx","xxx");
mysql_select_db("nijen8mudwebdk"$linkID);
$resultid=mysql_query("select text from content where subcat='synergi'"$linkID);

$textid=mysql_fetch_array($resultid);
$text=$textid[text];

if (
$resultid) {
echo 
"&text=".urlencode($text);
} else {
exit;
}
?>
And the actionscript:
PHP Code:
loadVarsText = new loadVars();
loadVarsText.gosub=_root.gosub;
loadVarsText.onLoad = function(success) {
    if (
success) {
        
trace("done loading");
        
scroller.text this.text;
    } else {
        
trace("not loaded");
    }
};

loadVarsText.sendAndLoad ("http://localhost/text.php"loadVarsText"POST"); 

Last edited by CyanBlue; 05-31-2004 at 12:03 PM. Reason: PHP tag is applied...
nikkelei is offline   Reply With Quote
Old 05-30-2004, 05:43 PM   #4
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default

nikkelei,

Hey, could you possibly use the [ PHP ] [/ PHP ] tags, because its a pain the ass to try and look through code when its not formatted right.

As for languages and character problems, i am not too sure on those matters, if you do a search on these forums, plenty of topics will come up on the issue. Someone else might read this post and reply according too.

Regards, snapple
snapple 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


All times are GMT. The time now is 02:13 AM.

///
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.