$value) { if (strpos($value, $find_string) !== false) { // Create a list of fields which contain the found string. $field_arr[$key] = true; //print_r($row_arr); } } } if (count($field_arr) == 0) { print " string not found."; } else { print " string found in field(s): " . implode(', ', array_keys($field_arr)) . "\n"; foreach (array_keys($field_arr) as $field) { if ($field != "guid") { $query = "UPDATE $table SET $field = replace($field, '$find_string', '$replace_string') WHERE $field LIKE '%$find_string%'"; update_table($query); } else { if ($replace_guid) { $query = "UPDATE $table SET $field = replace($field, '$find_string', '$replace_string') WHERE $field LIKE '%$find_string%'"; update_table($query); } else { print "\nString found in guid field but not replacing. Override this by using the --replace_guid_field flag.\n"; } } } } } function update_table($query) { print "\n$query\n"; $result = mysql_query($query); $num_updated = mysql_affected_rows(); print "... updated $num_updated records\n"; } ?>