# Add Array values that are numbers

**URL:** <https://forum.kirupa.com/t/add-array-values-that-are-numbers/221032>\
**Category:** flash\
**Created:** [March 31, 2007, 9:10pm UTC](https://forum.kirupa.com/t/add-array-values-that-are-numbers/221032 "2007-03-31T21:10:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbailey](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jbailey/32/2380_2.png) [@jbailey](https://forum.kirupa.com/u/jbailey)\
**Post date:** [March 31, 2007, 9:10pm UTC](https://forum.kirupa.com/t/add-array-values-that-are-numbers/221032/1 "2007-03-31T21:10:18Z")

</div>

**How do I add array values that are numbers when loaded dynamically via sql?**

Example script doesn’t calculate. Instead it just adds as though the elements of ycor array are string based. So ycor[0] = 2 and ycor[1] = 3 added equals 23 not 5. Of course these elements are being dynamically set via mysql db that generates a xml table. I’ve left out file locations and passwords for obvious reasons. **Why are the elements being treated as strings?**

```auto

var theXML:XML = new XML();
theXML.ignoreWhite = true;
theXML.onLoad = function(success:Boolean) {
    if (success) {
    main = [];
    caption = [];
    areaName = [];
    areaType = [];
    hyplnk = [];
    ycor = [];
    var nodes = this.firstChild;
    var total = nodes.childNodes.length;
    for(i=0;i<total;i++) {
        main* = nodes.childNodes*.attributes.main;
        caption* = nodes.childNodes*.attributes.caption;
        areaName* = nodes.childNodes*.attributes.areaName;
        areaType* = nodes.childNodes*.attributes.areaType;
        hyplnk* = nodes.childNodes*.attributes.hyplnk;
        ycor* = nodes.childNodes*.attributes.ycor;
    }
    images()
    }
    else {
            statusArea.text = "Could not load SQL database" + '
'
    }
    
}

func images(){
 statusArea.text = ycor[0] + ycor[1] //<--- This doesn't give me 5 it gives 23

}
theXML.load("GetInfo.php");

```

```php
<?PHP

$link = mysql_connect("location","user","pass");
mysql_select_db("db");

$query = 'SELECT * FROM table';
$results = mysql_query($query);

echo "<?xml version=\"1.0\"?>
";
echo "<menu>
";

while($line = mysql_fetch_assoc($results)) {
    echo "<subitem main='". $line["main"] . "' caption='". $line["caption"] . "' hyplnk='". $line["hyplnk"] . "' ycor='". $line["ycor"] . "'></subitem>
";
    //echo "<subitem>" . $line["main"] . "</subitem>
";
}

echo "</menu>
";

mysql_close($link);

?>

```
