MYSQL Search Replace

I wrote this to search and replace any entries on a text string with another text string. It searches all fileds in all tables of the $dbname specified.
[code lang=”php”]
< ? $dbname = "proche"; $result = mysql_list_tables($dbname); while ($row = mysql_fetch_row($result)) { $table_name= $row[0]; $fields = mysql_list_fields($dbname, $table_name, $link_id); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_name = mysql_field_name($fields, $i); $sql = "update proche.".$table_name." set ".$field_name; $sql .= " = Replace(".$field_name.", 'http://redbrick.dcu.ie',"; $sql .= "'http://www.redbrick.dcu.ie')"; $sqlresult = mysql_query($sql, $link_id); }//end for }//end while mysql_free_result($result); ?>
[/code]