# PHP variable into Flash?

**URL:** https://forum.kirupa.com/t/php-variable-into-flash/309782
**Category:** flash
**Created:** [May 24, 2010, 10:42pm UTC](https://forum.kirupa.com/t/php-variable-into-flash/309782 "2010-05-24T22:42:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Hacee](https://avatars.discourse-cdn.com/v4/letter/h/858c86/32.png) [@Hacee](https://forum.kirupa.com/u/Hacee)
#### Post date: [May 24, 2010, 10:42pm UTC](https://forum.kirupa.com/t/php-variable-into-flash/309782/1 "2010-05-24T22:42:15Z")

</div>

Hi!

I’ve got a problem with getting a PHP-variable into Flash with AS3. I haven’t done much AS3 programing but I know how to send variables, however this time I just want retrieve 1 from PHP(with a value from a MySQL database) into a textInput in Flash.

I’ve tried different tutorials but nothing seems to work for me.  
This is my PHP script:

//this line is the call from flash, don’t know if it’s correct.  
if ($\_POST[‘getDataRequest’] == “getBmr” ){

```
$uid = $_SESSION['uid'];
$bmr = $_POST['bmr'];
$uid = 1;

$query = "SELECT bmr FROM tblBmr WHERE uid='" . $uid . "' ORDER

```

BY DATE DESC LIMIT 0,1";  
print\_r($query);  
$result\_set = mysql\_query($query);  
confirm\_query($result\_set);

```
while ($row = mysql_fetch_assoc($result_set)) {

//I get the correct value when i echo this so i'm doing something right
echo $row['bmr'];

$bmrValue = $row['bmr'];

//from what i've seen in tutorials, this is what flash will retrieve:
print "bmr="$bmrValue; 

//but i can't get it to work

```

}  
}

This is my AS3, don’t know if it’s correct either 🙂 :

function getBmrNr(e:MouseEvent):void {

var getBmrDB:URLVariables = new URLVariables();

var phpBurn:String = “[http://www.mysite.com/flashData.php](http://www.mysite.com/flashData.php)”;

var getBmrDB\_send:URLRequest = new URLRequest(phpBurn);  
getBmrDB\_send.method = URLRequestMethod.POST;  
getBmrDB\_send.data = getBmrDB;

var getBmrDB\_varLoader:URLLoader = new URLLoader;  
getBmrDB\_varLoader.dataFormat = URLLoaderDataFormat.TEXT;  
getBmrDB\_varLoader.addEventListener(Event.COMPLETE, recievingData);

```
    getBmrDB.getDataRequest = "getBmr";
    getBmrDB_varLoader.load(getBmrDB_send);

```

function recievingData(e:Event):void{

```
var phpVar1 = e.target.data.bmr;
bmrField.text = phpVar1;   
}

```

}

minField.addEventListener(MouseEvent.CLICK, getBmrNr);

Would be VERY thankful for any help, it’s a college group project…  
I’ll get my a\*\* kicked if I don’t deliver 🙂

Cheers,

Hacee
