how to regenerate phpbb_topics
if phpbb_topics table is corrupted and you need to regenerate it, you can use this script:
<?php
//———————-//
// phpbb_topics Bappear //
//———————-//
include “config.php”;
$abc = mysql_connect($dbhost, $dbuser, $dbpasswd);
mysql_select_db($dbname);
$aaa = mysql_query(“SELECT ” . $table_prefix . “posts.topic_id, ” . $table_prefix . “posts.forum_id, ” . $table_prefix . “posts.poster_id, ” . $table_prefix . “posts.post_time, not ISNULL(” . $table_prefix . “vote_desc.topic_id) as vote_topic_id, (count(” . $table_prefix . “posts.post_id) – 1) as topic_replies, IF(ISNULL(” . $table_prefix . “posts_text.post_subject), ‘Generic Title’, ” . $table_prefix . “posts_text.post_subject) as post_subject, ” . $table_prefix . “posts_text.post_id as topic_first_post_id, max(” . $table_prefix . “posts_text.post_id) as topic_last_post_id FROM `” . $table_prefix . “posts` LEFT JOIN ” . $table_prefix . “vote_desc ON ” . $table_prefix . “posts.topic_id = ” . $table_prefix . “vote_desc.topic_id LEFT JOIN ” . $table_prefix . “posts_text ON ” . $table_prefix . “posts.post_id = ” . $table_prefix . “posts_text.post_id GROUP BY ” . $table_prefix . “posts.topic_id;”, $abc);
while($data = mysql_fetch_array($aaa)) {
mysql_query(“INSERT INTO `” . $table_prefix . “topics` (`topic_id`, `forum_id`, `topic_title`, `topic_poster`, `topic_time`, `topic_views`, `topic_replies`, `topic_status`, `topic_vote`, `topic_type`, `topic_first_post_id`, `topic_last_post_id`, `topic_moved_id`) VALUES(” . $data['topic_id'] . “, ” . $data['forum_id'] . “, ‘” . mysql_real_escape_string($data['post_subject']) . “‘, ” . $data['poster_id'] . “, ” . $data['post_time'] . “, 0, ” . $data['topic_replies'] . “, 0, ” . $data['vote_topic_id'] . “, 0, ” . $data['topic_first_post_id'] . “, ” . $data['topic_last_post_id'] . “, 0);”);
}
mysql_free_result($aaa);
mysql_close($abc);
?>
this script was created by one of my forums member, Nachum.
Thanks – It was a real save.

My name is Guy Mizrahi and I am a Security Specialist from Israel.
Go to the About page to read more about me.