title: Updating php serialize array value in database
body: <p>So we have historic logs in a database that contain old user data. We don't want to delete the logs but rather just *** out some of the data that is in there. Its stored in MySQL in a field as an array that has been serialized.</p>
  
  <pre><code>a:1:{s:4:"Test";s:17:"user data";} 
  </code></pre>
  
  <p>How can I update the value of test (user data)? either via MySQL or php so it would look like the below? This effects hundreds of rows.</p>
  
  <pre><code>a:1:{s:4:"Test";s:17:"***";} 
  </code></pre>
  
  <p>This is what I have just tried to retrieve some data</p>
  
  <pre><code>$sqltext = "SELECT log_data FROM log WHERE log_data != '' LIMIT 1";
  $result = mysql_query ($sqltext) or die(SqlError(__FILE__,__LINE__,__FUNCTION__));
  
  $row = mysql_fetch_array($result);
  $deserialized = unserialize($row-&gt;log_data);
  var_dump($deserialized);
  </code></pre>
  
  <p>which returns this: bool(false) </p>
  
  <p>The array contains a bunch of stuff including html</p>