$sql = 'SELECT post_id, post_text FROM ' . POSTS_TABLE; $result = $db->sql_query($sql); $inctimes = 0; while ($row = $db->sql_fetchrow($result)) { $message_parser->message = &$row['post_text']; $regexp = '/\<div class=\"quote\"\>.*Quoting: ([^&]*)<\/div>([^&]*)<\/div>/iUe'; $times = 0; $times = preg_match_all($regexp, $message_parser->message, $matches); if($times > 0){ echo '

' . $row['post_id'] . ' has ' . $times . ' match(es).

'; } $inctimes = $inctimes + $times; preg_replace($regexp,"[quote=\"$1\"]$2[/quote]",$message_parser->message); //Update DB with change $sql = 'UPDATE ' . POSTS_TABLE . ' SET post_text = ' . $db->sql_escape($message_parser->message) . ' WHERE post_id = ' . $row['post_id']; $db->sql_query($sql); } echo '

There should be ' . $inctimes . ' modifications to the database

';