# Passing Variables from PHP to Flash

**URL:** <https://forum.kirupa.com/t/passing-variables-from-php-to-flash/279365>\
**Category:** flash\
**Created:** [January 13, 2009, 11:27pm UTC](https://forum.kirupa.com/t/passing-variables-from-php-to-flash/279365 "2009-01-13T23:27:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThaJock](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@ThaJock](https://forum.kirupa.com/u/ThaJock)\
**Post date:** [January 13, 2009, 11:27pm UTC](https://forum.kirupa.com/t/passing-variables-from-php-to-flash/279365/1 "2009-01-13T23:27:12Z")

</div>

I have never had a problem passing variables from PHP to flash until now. The difference is that I’m trying to pass an IP Address.

Action Script 3:

var url:String = “[http://localhost:8888/TheTest.php](http://localhost:8888/TheTest.php)”;  
var request:URLRequest = new URLRequest(url);  
request.method = URLRequestMethod.POST;//select the method as post  
var loader:URLLoader = new URLLoader();  
loader.addEventListener(Event.COMPLETE, handleComplete);  
loader.load(request);//send the request with URLLoader()

function handleComplete(event:Event) {  
var loader:URLLoader = URLLoader(event.target);  
var vars:URLVariables = new URLVariables(loader.data);  
//Access data from the PHP file  
trace(vars.ip);  
}

PHP:

\<?php

$ip = $\_SERVER[‘SERVER\_ADDR’];  
echo “ip=$ip”;

?\>

When I test it it traces ::1  
However if in the php file I change it to the following code I traces 1022545 as it should.

\<?php

echo “ip=1022545”;

?\>

I even tried to set the dataType in php:

\<?php

$ip = $\_SERVER[‘SERVER\_ADDR’];  
settype($ip,“string”);  
echo “ip=”$ip";

?\>

I’m not sure why it’s different. If anyone can help me with this one I would appreciate it.
