# PHP Variable to AS3 Question

**URL:** <https://forum.kirupa.com/t/php-variable-to-as3-question/301131>\
**Category:** flash\
**Created:** [December 3, 2009, 7:31pm UTC](https://forum.kirupa.com/t/php-variable-to-as3-question/301131 "2009-12-03T19:31:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonder](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bonder](https://forum.kirupa.com/u/bonder)\
**Post date:** [December 3, 2009, 7:31pm UTC](https://forum.kirupa.com/t/php-variable-to-as3-question/301131/1 "2009-12-03T19:31:55Z")

</div>

While I am aware that there is a way for AS3 to get variables from PHP I simply cannot get any of the ways I have seen to work. I have spent several hours on these forums and visited a number of different pages and none of the methods that people have proposed seem to work for me.

I have constructed an super simplified example of what I am trying to do so that anyone interested to take a look. My problem is that I want to trace a variable that is assigned in PHP to the flash output window, but I can’t even get it to do that. Every time I do this it comes up undefined. What is going on here because as far as I can tell I am doing all the things that other people say to do and it still will not work.

Its also worth noting that I am developing in MAMP, will that affect anything? It has not in the past I have had a very good experience working with flash and php before in MAMP.

Here is the simplified example for you all to take a look at:  
The actionscript 3 code:  
ActionScript Code:  
[LEFT][COLOR=#993300]var[/COLOR] loader:URLLoader = [COLOR=#993300]new[/COLOR] URLLoaderCOLOR=#000000[/COLOR];  
[COLOR=#993300]var[/COLOR] request:URLRequest = [COLOR=#993300]new[/COLOR] URLRequestCOLOR=#000000[/COLOR];[COLOR=#F000F0]_/////they are in the same folder in my test environment_[/COLOR]  
request.[COLOR=#000000]method[/COLOR] = URLRequestMethod.[COLOR=#000000]POST[/COLOR];

loader.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000000]COMPLETE[/COLOR], completeHandler[COLOR=#000000])[/COLOR];  
loader.[COLOR=#000000]dataFormat[/COLOR] = URLLoaderDataFormat.[COLOR=#000000]VARIABLES[/COLOR];  
loader.[COLOR=#993300]load[/COLOR]COLOR=#000000[/COLOR];

[COLOR=#993300]function[/COLOR] completeHandlerCOLOR=#000000[/COLOR]:[COLOR=#993300]void[/COLOR]  
[COLOR=#000000]{[/COLOR]  
[COLOR=#993300]trace[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#F000F0]_//// i want the name_[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[/LEFT]

and the php (note i tested this single page and the output works fine, no php errors):  
PHP Code:  
[COLOR=#000000] [COLOR=#0000BB]\<?php  
$user [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]“bob”[/COLOR][COLOR=#007700];  
echo [/COLOR][COLOR=#DD0000]“user=”[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$user[/COLOR][COLOR=#007700];  
[/COLOR][COLOR=#0000BB]?\>[/COLOR] [/COLOR]
