<?php
$result = sql_select_field($config['table_prefix'] . 'fields', 'id, table_id, name_field, type_field, type_value');
while ($row = sql_fetch_assoc($result)) {
    $row['int_name'] = form_int_name($row['id'], $row['type_field']);
    $searches[$row['table_id']][] = '{' . $row['name_field'] . '}';
    $replaces[$row['table_id']][] = '{' . $row['int_name'] . '}';
    if ($row['type_field'] == 5) {
        $result2 = sql_select_field($config['table_prefix'] . 'fields', 'id, table_id, name_field, type_field', 'table_id = ', explode('|', $row['type_value'])[0]);
        while ($row2 = sql_fetch_assoc($result2)) {
            $row2['int_name'] = form_int_name($row2['id'], $row2['type_field']);
            $searches[$row['table_id']][] = '{' . $row['name_field'] . '.' . $row2['name_field'] . '}';
            $replaces[$row['table_id']][] = '{' . $row['int_name'] . '.' . $row2['int_name'] . '}';
        }
    }
}
$result = sql_select_field($config['table_prefix'] . 'tips', 'id, table_id, message, email_subject, solution');
while ($row = sql_fetch_assoc($result)) {
    sql_update($config['table_prefix'] . 'tips', [
        'message' => str_replace($searches[$row['table_id']], $replaces[$row['table_id']], $row['message']),
        'email_subject' => str_replace($searches[$row['table_id']], $replaces[$row['table_id']], $row['email_subject']),
        'solution' => str_replace($searches[$row['table_id']], $replaces[$row['table_id']], $row['solution']),
    ], 'id = ', $row['id']);
}