# loadVars fail to show the first variable from PHP

**URL:** <https://forum.kirupa.com/t/loadvars-fail-to-show-the-first-variable-from-php/223907>\
**Category:** flash\
**Created:** [April 26, 2007, 4:19pm UTC](https://forum.kirupa.com/t/loadvars-fail-to-show-the-first-variable-from-php/223907 "2007-04-26T16:19:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iam\_curious](https://avatars.discourse-cdn.com/v4/letter/i/8e7dd6/32.png) [@iam\_curious](https://forum.kirupa.com/u/iam_curious)\
**Post date:** [April 26, 2007, 4:19pm UTC](https://forum.kirupa.com/t/loadvars-fail-to-show-the-first-variable-from-php/223907/1 "2007-04-26T16:19:47Z")

</div>

Hello all!  
I’m a new member and surprise surprise Iam struggling with the following problem.  
Thanks in advance for any help.

I have a php file (select.php) that retrieves data from the MySQL database.  
When I load the ‘select.php’ it shows the result as expected.  
This means my problem is not in PHP but in Flash!

In Flash MX2004, I got the following code on frame 2

- stop();  
myData = new LoadVars();  
myData.onLoad = function(succes) {  
if (succes) {  
trace(myData);  
//these buttons were made invisible in the first frame.  
bt\_0.\_visible=1;  
bt\_1.\_visible=1;  
} else {  
trace(“Error loading data”);  
}  
};  
myData.load(“[http://localhost/select.php](http://localhost/select.php)”);\*

When Flash recieves it through ‘loadVars’ it activates the ‘_trace(myData)_’ function and ouputs as follows:

- selected%5Fdata=5%0D%0A%0D%0A%0D%0A%0D%0A&image%5Ffile4  
=Pic%5FFour&content4=Content%5FFour&title4=Title%5FFour&image%5  
Ffile3=Pic%5FThree&content3=Content%5FThree&title3=Title%5FThree&  
image%5Ffile2=Pic%5FTwo&content2=Content%5FTwo&title2=Title%5FTwo  
&image%5Ffile1=Pic%5Fone&content1=Content%5FOne&title1=Title%5FOne  
&image%5Ffile0=Pic%5Fzero&content0=Content%5FZero&%0D%0A%0D%0A  
[COLOR=Red]title0=Title%5FZero[/COLOR]&onLoad=%5Btype%20Function%5D\*

‘_[COLOR=Red]title0=Title%5FZero[/COLOR]_’ red to highlight the problem variable.  
The above traced result shows that all the variables are loaded into Flash.

So the problem is not there either!

But whenever I access it later, whether through a button event or another trace function the first variable (_[COLOR=Red]title0=Title%5FZero[/COLOR]_) shows as ‘_undefined_’.

All other variables are available and works fine.  
But ‘[COLOR=Red]_title0_[/COLOR]’ was just traced as '_[COLOR=Red]Title%5FZero’[/COLOR]_ in the \*‘myData.onLoad’ \*function!  
Now it shows as ‘_undefined_’!!

So the problem lies in the first variable only. But how? I couldn’t find an explanation within my limited actionscript knowledge.  
I did a lot of search on web and in books, but all in vain!

I use the code below to access the variables.

- function show\_me (me) {  
title\_txt.text = myData[“title”+me];  
content\_txt.text = myData[“content”+me];  
image\_txt.text=myData[“image\_file”+me];  
}\*

Button code on ‘bt\_0’ and ‘bt\_1’ respectively -

- on(release){  
show\_me (0);  
}

on(release){  
show\_me (1);  
}\*

Any help will be highly appreciated.

Thanks  
And Iam still curious!
