# Php array to flash as 2 fill combo box problem

**URL:** <https://forum.kirupa.com/t/php-array-to-flash-as-2-fill-combo-box-problem/292317>\
**Category:** programming\
**Created:** [July 13, 2009, 10:24am UTC](https://forum.kirupa.com/t/php-array-to-flash-as-2-fill-combo-box-problem/292317 "2009-07-13T10:24:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IsmaelDemiddel](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@IsmaelDemiddel](https://forum.kirupa.com/u/IsmaelDemiddel)\
**Post date:** [July 13, 2009, 10:24am UTC](https://forum.kirupa.com/t/php-array-to-flash-as-2-fill-combo-box-problem/292317/1 "2009-07-13T10:24:41Z")

</div>

Hello

I seem to keep getting a problem to fill a combo box in flash CS3 (actionscript 2.0)  
I made a php file wich reads data from a mysql table and then puts it in an array (this works fine. I seperated it to data and label(name) and afterwards exported it to read it in flash as data and label. But when I read it in flash nothing happens, I keep getting ‘undefined’…  
Here’s my code:

Combolist.php:  
\<?  
//connect to database  
mysql\_connect(“localhost”,“username”,“passwoord”) or die (“didn’t connect to mysql” . mysql\_error());  
mysql\_select\_db(“combolistinfo”) or die (“no database” . mysql\_error());  
//make query  
$query = “SELECT list FROM combo”;  
$result = mysql\_query( $query ) or die (“didn’t query” . mysql\_error());

$num = mysql\_num\_rows( $result );  
$ComboName = array();  
$ComboData = array();  
$j = 0;  
while ($row = mysql\_fetch\_row($result)){  
$ComboName[$j] =$row[0];  
$ComboData[$j] =$row[0];  
$data[] = $ComboName[$j].":".$ComboData[$j];  
$j++;  
}  
print implode("  
",$data);  
mysql\_close($DBConn);  
?\>

so this above works properly!!

flash fill combolist.fla:

tmp=new Array();  
tmp2=new Array();

//make new loadvar  
myDataCombo = new LoadVars();  
//load php file  
myDataCombo.load(“Combolist.php”);  
//get data from php file  
myDataCombo.onData = function(raw) {  
//split data to fill array  
tmp = raw.split("  
");

```
for (var i = 0; i&lt;tmp.length; i++) {
    tmp2 = tmp*.split(":");
    _root.cmblist.addItem(tmp2[0],tmp2[1]);
}

```

};  
//execute function  
traceCombo();  
//function to read data and label that is selected  
function traceCombo(com) {  
trace("Selected Data: "+com.getSelectedItem().data);  
trace(“Selected Label: “+com.getSelectedItem().label);  
trace(”--------------------------------------”);  
}

I tried it a couple of times with other possiblities, but it didn’t work. Please help me on this!

Thanks already!
