# http\_build\_query() and URLRequest - an annoying problem

**URL:** <https://forum.kirupa.com/t/http-build-query-and-urlrequest-an-annoying-problem/288359>\
**Category:** flash\
**Created:** [May 14, 2009, 5:30pm UTC](https://forum.kirupa.com/t/http-build-query-and-urlrequest-an-annoying-problem/288359 "2009-05-14T17:30:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kloucek](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@Kloucek](https://forum.kirupa.com/u/Kloucek)\
**Post date:** [May 14, 2009, 5:30pm UTC](https://forum.kirupa.com/t/http-build-query-and-urlrequest-an-annoying-problem/288359/1 "2009-05-14T17:30:10Z")

</div>

Hi,

I’m working to gain some proficiency in communicating flash and php. I recently found this nice method to feed variables from php into flash.

I’m using http\_build\_query() function in a php file to send some variables like this:

```php
$users = mysql_query("SELECT * FROM users WHERE uid=666");
$ua = mysql_fetch_array($users);

$vars = array();

$vars['user_id'] = $ua[0]; //should be 666
$vars['pet_id'] = $ua[1]; //should be 777
$vars['cash'] = $ua[2]; //should be 120
$vars['advicepoints'] = $ua[3]; //should be 5
$vars['AP'] = $ua[4]; //ahould be 100
$vars['timestamp'] = $ua[5]; //should be 1242291847078
$vars['income'] = $ua[6]; //should be 24
$vars['attractiveness']= $ua[7]; //should be 14

$returnString = http_build_query($vars);
echo $returnString;

```

It gives a nice and expected output in the browser:

```auto
user_id=666&pet_id=777&cash=120&advicepoints=5&AP=100&timestamp=1242291847078&income=24&attractiveness=14

```

Then in flash I grab those variables using:

```auto
var request:URLRequest = new URLRequest("http://localhost/~sandbox/send_data.php");
            request.method = URLRequestMethod.GET;
            
            var loader:URLLoader = new URLLoader();
                loader.dataFormat = URLLoaderDataFormat.VARIABLES;
                loader.addEventListener(Event.COMPLETE, completeHandler);
                loader.load(request);
                
                function completeHandler(evt:Event) {
                
                    trace (evt.target.data);
                    
                    
                }

```

The output of trace is not so obvious and expected (at least to me):

```auto
advice%5Fpoints=5&AP=100&income=24&timestamp=1242291847078&pet%5Fid=777&attractiveness=14&cash=120&%20uid=666

```

First of all the order of the output is a mystery to me. It’s not in alphabetical order, it’s not in numerical order and FIRST OF ALL it’s not in the order i’ve put it 😕 (but that also happened to me when i was trying out multiple flashVars, so i just assume, that’s just Adobe idea for a joke… 😉 ).

EDIT - oh, i’ve noticed, that this order IS vurnerable to changes. However those are equally uncomprehensible to me as well

Second - the misterious “%20” (space?!?) before uid var. Now how did you get there “%20” and why do i get the feeling you are my problem?!?

And finally when i trace all the variables evt.target.data.\<var name\> only uid comes as undefined…

And the last sentence more or less wraps up my problem. How the heck can i trace uid(and later do more unmoral things with it)?

Oh please, oh please help me kirupa forum 🙂
