# Loading Flash Variables using PHP

**URL:** <https://forum.kirupa.com/t/loading-flash-variables-using-php/318138>\
**Category:** flash\
**Created:** [January 11, 2011, 1:41pm UTC](https://forum.kirupa.com/t/loading-flash-variables-using-php/318138 "2011-01-11T13:41:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicguy](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@musicguy](https://forum.kirupa.com/u/musicguy)\
**Post date:** [January 11, 2011, 1:41pm UTC](https://forum.kirupa.com/t/loading-flash-variables-using-php/318138/1 "2011-01-11T13:41:33Z")

</div>

The flash php script I am using works fine with variables assigned directly from the script. Once I use php to gather the variables dynamically it does not work. Any help would be appreciated.

Here is an example that works:  
\<?php  
$tour\_city = ‘WALNUT CREEK ~ $1,450,000’;  
$tour\_address = ‘55570 PACIFIC HEIGHTS, WALNUT CREEK, CA’;  
$tour\_unid = ‘TOUR #644657’;  
$tour\_mls = ‘MLS #40465821’;  
echo “city\_price=” . $tour\_city . “&” . “address=” . $tour\_address . “&” . “tour\_id=” . $tour\_unid . “&” . “mls\_id=” . $tour\_mls;  
?\>

Here is the example the does not work:

\<?php

function load\_data()

echo “city\_price=” . $tour\_city . “&” . “address=” . $tour\_address . “&” . “tour\_id=” . $tour\_unid . “&” . “mls\_id=” . $tour\_mls;

{

$tour\_id = ‘435’;

//connection to the database  
$dbhandle = mysql\_connect($hostname, $username, $password)  
or die(“Unable to connect to MySQL”);

$selected = mysql\_select\_db(“testaccount”,$dbhandle)  
or die(“Could not select examples”);

$query=“SELECT \* FROM `tour_list` WHERE tour\_list\_id=$tour\_id”;  
$result=mysql\_query($query);  
$row = mysql\_fetch\_assoc($result);

$tour\_address = $row[‘tour\_address’];

$tour\_city = $row[‘tour\_city’];

$tour\_mls = $row[‘tour\_mls’];

$tour\_unid = $row[‘tour\_unid’];

//close the connection  
mysql\_close($dbhandle);

}

?\>

Here is the flash code:

var phpFile:String = “info.php”;

var myLoader:URLLoader = new URLLoader();

myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

var urlRequest:URLRequest = new URLRequest(phpFile);

myLoader.load(urlRequest);

myLoader.addEventListener(Event.COMPLETE, loadComplete);

function loadComplete(evt:Event):void {  
// Display the value with variable name “Candidate”  
city\_price\_txt.text = evt.target.data.city\_price;

//Display the value with variable name “Date”  
address\_txt.text = evt.target.data.address;

tour\_id\_txt.text = evt.target.data.tour\_id;

mls\_id\_txt.text = evt.target.data.mls\_id;

}

I have been trying to see what the problem is and can’t make it work.

Thank you to any one that can help.
