views:

39

answers:

0

This is my first time here and I have been pulling my hair out over this one, so I thought it would be a good first question for me.

I am saving some array data to a mysql database, and then later I am using unserialize to edit it. The problem is that it blanks out every other index in the array when I edit just one index. Here is some example code:

foreach($post as $key => $value)  {
     if (isset($row)) {
        if ($i > 2) { $tempArray = unserialize($row[$i]); }
     }

     $tempArray[$time] = $value;

     if ($key == 'pid' || $key == 'uid') { $data[$key] = $value; }
     else { $data[$key] = serialize($tempArray); }
     $i += 1;
     unset($tempArray);
  }

Thanks for any insight you can give.