Avatar of plutonium05
plutonium05

asked on 

Receiving multiple variables from PHP into multiple dynamic text boxes in Flash AS3

I have a Flash file that gets a user ID from the URL, this works, and sends it to a PHP file to retrieve data. I am trying to retrieve two variables and put each of them in their own dynamic text boxes. What ends up happening is everything is placed in the first dynamic text box and it looks like: ThisFirmsNamephonenumber=9384829283         It's almost like the flash file is not recognizing the & to separate the name/value pairs. I have also tried the PHP file with no function and simpler echo using the & but that did not work either. Thanks for your help!
AS3:
 
var request:URLRequest = new URLRequest ("http://localhost/nsert.php");
request.method = URLRequestMethod.POST;
				
var variables:URLVariables = new URLVariables();
				
variables.idtag = this.loaderInfo.parameters.id;			
variables.phonenumber = "";
variables.firmname = "";
request.data = variables;
				
var loader:URLLoader = new URLLoader (request);
 
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(request);
 
loader.addEventListener(Event.COMPLETE, onComplete);
 
function onComplete (event:Event):void
{
    var variables:URLVariables = new URLVariables( event.target.data );
	phone.text = variables.phonenumber;
    firmname.text = variables.firmname;
}
 
 
 
 
 
 
PHP:
 
<?php
   //Capture data from $_POST array
   $id=$_POST['idtag'];
   //Connection to database
   $connect = mysql_connect("****","****","******");
   mysql_select_db ("databasename", $connect);
   //Perform the query
   $result = mysql_query("SELECT firmname, phone FROM tablename WHERE selector=$id");
   $row = mysql_fetch_row($result);
   $firmname = $row[0];
   $phonenumber = $row[1];
   
$numVariables = 0;
 
function writeVariable( $name, $value )
{
    if( $numVariables > 0 )
    {
        echo "&";
    }
 
    echo $name . "=" . urlencode($value);
 
    $numVariables ++;
}
 
writeVariable( "firmname", $firmname );
writeVariable( "phonenumber", $phonenumber );
 
mysql_close($connect);
?>

Open in new window

PHPAdobe Flash

Avatar of undefined
Last Comment
pixel1024
ASKER CERTIFIED SOLUTION
Avatar of qwynia
qwynia

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of plutonium05
plutonium05

ASKER

Thank you very much, I got it working!
Avatar of qwynia
qwynia

You're welcome, glad I could help.
Avatar of pixel1024
pixel1024

Thanks qwynia - this is a very useful post!
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo