# Using Shared Object data to populate a MySQL table

**URL:** <https://forum.kirupa.com/t/using-shared-object-data-to-populate-a-mysql-table/278974>\
**Category:** flash\
**Created:** [January 8, 2009, 5:20am UTC](https://forum.kirupa.com/t/using-shared-object-data-to-populate-a-mysql-table/278974 "2009-01-08T05:20:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [January 8, 2009, 5:20am UTC](https://forum.kirupa.com/t/using-shared-object-data-to-populate-a-mysql-table/278974/1 "2009-01-08T05:20:11Z")

</div>

I’ve got a sequence of numbers in a Shared Object that I would like to write to an MySQL database table. I’m thinking that the data items in the SO should be turned into an array:

```auto

var soldItemSO:SharedObject = SharedObject.getLocal("soldItems", "/");
var soldItemNum:Array = [];
for (var i:Number = 1; i <= 10; i++) {
    if (soldItemSO.data* != undefined) {
        soldItemNum[i - 1] = soldItemSO.data*;
    }
}

```

And then some code to send the vars:

```auto

var LoadVarsSender:LoadVars = new LoadVars();
LoadVarsSender.onLoad = function(success:Boolean) {
    if (success) {
        trace("success");
}
LoadVarsSender.soldItem = soldItemNum; //Problem spot
LoadVarsSender.sendAndLoad("writeToDbase.php",LoadVarsSender,"POST");
}

```

And PHP to write to the database:

```auto

(writeToDbase.php)

<?php
$soldItem = $_POST['soldItem'];

$link = mysql_connect("localhost", "root","password") or die ("Unable to connect to database.");
mysql_select_db("gallery") or die ("Unable to select database.");
$sqlstatement= "INSERT INTO products (artworks) VALUES ('$artworks')";
mysql_close($link);
?>

```

I’m confused about how I would write individual rows into the database table since “soldItemNum” is going to have a number of data slots, and each slot should end up as a single row in the database table. Does that make sense? I’m not sure where I should loop through the array of items.
