What are the differances in the MySQL database between 4.6 and 4.7 that would effect a migrating script?

I am trying to convert phpBB 2.0.11 to Drupal 4.7. I've been trying to update the MySQL conversion script to drupal 4.7. It seems as the users and forum containers get converted great. The problem I'm having is with the forum topics and comments. When you view the forum container, it displays the correct number of topics and posts for each forum. Then when you click on the individual forums, all the posts are messed up. Most of them say that the topic has been moved. When I'm able to click on an individual topic, it contains posts from other topics.

Can someone please help me find the problem? The script I am currently using (not yet working, see above) is here:

#
# Written by Feodor (feodor [at] mundo.ru)
#
# Modified for drupal 4.5.2 and phpbb 2.0.11-2.0.13
# by Alexander Mikhailian <mikhailian@altern.org>
#
# This script makes an assumption that phpbb and drupal tables are kept in
# one and the same database. Phpbb tables are expected to have the prefix
# phpbb_ and drupal tables are expected to have the prefix 
#
# If phpBB forum use CP1251 (or another) encoding, the tables must be converted
# into UTF8. If version of MySQL less then 4.1 "iconv" command can be used for
# convertion of exported tables into UTF8.
#
# Example:
# iconv -fcp1251 -tutf8 < phpbb2.sql > phpbb2_utf-8.sql
#
# Here is a list of phpbb tables used by script for import into Drupal:
#
# <*> phpbb_categories
# <*> phpbb_forums
# <*> phpbb_posts
# <*> phpbb_posts_text
# <*> phpbb_users
# <*> phpbb_vote_desc
# <*> phpbb_vote_results
#
# You should probably edit the two variables below to match your result:

#
# The name of the forums taxanomy as it appears on the site
#
SELECT @forum_title:='Forums';


# Start importing users from this id. Do not forget that uid 1 is always 
# the Administrator in Drupal. Depending on whether you already created
# the Administrator user in Drupal or not, you may want to change this
# variable into 2.
#
SELECT @first_phpbb_user_id:=6; # uid 1 is always an administrator in Drupal

#
# Drupal variables for node counts
#
SELECT @phpbb_terms:=MAX(forum_id) FROM phpbb_forums;
SELECT @phpbb_cat:=MAX(cat_id) FROM phpbb_categories;
SELECT @term_data_tid:=id FROM sequences WHERE name = 'term_data_tid';
  SELECT IF( @term_data_tid>0,  @term_data_tid, @term_data_tid:=0);
SELECT @comments_cid:=id FROM sequences WHERE name = 'comments_cid';
  SELECT IF( @comments_cid>0,  @comments_cid, @comments_cid:=0);
SELECT @vocabulary_vid:=id FROM sequences WHERE name = 'vocabulary_vid';
  SELECT IF( @vocabulary_vid>0,  @vocabulary_vid, @vocabulary_vid:=0);
SELECT @node_nid:=id FROM sequences WHERE name = 'node_nid';
  SELECT IF( @node_nid>0,  @node_nid, @node_nid:=0);

#
# Import user forms phpbb_users
#
INSERT INTO users (uid,name,pass,mail,mode,sort,threshold,theme,signature,created,status,timezone,language,picture,init,data)
  SELECT  user_id,username,user_password,user_email,0,0,0,'',user_sig,user_regdate,1,0,'',user_avatar,user_email,'a:1:{s:5:"roles";a:1:{i:0;s:1:"2";}}'
  FROM phpbb_users
  WHERE user_id>=@first_phpbb_user_id;

#
# Create a vocabulary (called "Forum")
#
DELETE FROM vocabulary WHERE module='forum';
INSERT INTO vocabulary (vid,name,description,help,relations,hierarchy,multiple,required,module,weight)
  SELECT @vocabulary_vid+1,@forum_title,'','','0','2','0','1','forum','0';


# Set up the vocabulary "Forum" as the forum vocabulary

DELETE FROM variable WHERE name = 'forum_nav_vocabulary';
INSERT INTO variable (name, value) VALUES ('forum_nav_vocabulary', CONCAT('s:1:\"',@vocabulary_vid+1,'\";'));

#
# The default comment order in phpbb2 is "oldest first"
#
DELETE FROM variable WHERE name = 'comment_default_order';
INSERT INTO variable (name, value) VALUES ('comment_default_order', 's:1:\"2\";');

#
# Import categories from phpbb_categories as terms
#
INSERT INTO term_data (tid,vid,name,weight)
  SELECT @term_data_tid+cat_id,@vocabulary_vid+1,cat_title,cat_order
  FROM phpbb_categories;
  
#
# Import terms from phpbb_forums
#  
INSERT INTO term_data (tid,vid,name,description,weight)
  SELECT @term_data_tid+@phpbb_cat+forum_id,@vocabulary_vid+1, forum_name,forum_desc,forum_order
  FROM phpbb_forums;

ALTER TABLE term_data ORDER BY tid;


# Import forum hierarchy 
# Drupal allows topics to be created at this level while phpbb2 does not. If you want to disallow topics below
# categories, mark them as containers in the forum configuration dialog
#
INSERT INTO term_hierarchy (tid,parent)
  SELECT @term_data_tid+cat_id,'0'
  FROM phpbb_categories;

INSERT INTO term_hierarchy (tid,parent)
  SELECT @term_data_tid+@phpbb_cat+forum_id, @term_data_tid+cat_id
  FROM phpbb_forums;
  
ALTER TABLE term_hierarchy ORDER BY tid;

#
# Create temporary tables for sorting topics and comments.
#

DROP TABLE IF EXISTS temp_posts;
CREATE TABLE temp_posts (
   post_id mediumint(8) UNSIGNED NOT NULL auto_increment,
   topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
   forum_id smallint(5) UNSIGNED DEFAULT '0' NOT NULL,
   poster_id mediumint(8) DEFAULT '0' NOT NULL,
   post_time int(11) DEFAULT '0' NOT NULL,
   post_edit_time int(11),
   post_subject char(512),
   post_text text,
   PRIMARY KEY (post_id),
   KEY forum_id (forum_id),
   KEY topic_id (topic_id),
   KEY poster_id (poster_id),
   KEY post_time (post_time)
);
DROP TABLE IF EXISTS temp_node;
CREATE TABLE temp_node (
   post_id mediumint(8) UNSIGNED NOT NULL auto_increment,
   topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
   PRIMARY KEY (post_id),
   KEY topic_id (topic_id)
);
   

# Copy into temporary table topics without comments

INSERT INTO temp_node (post_id,topic_id)
  SELECT MIN(post_id), topic_id
  FROM phpbb_posts
  GROUP BY topic_id;
INSERT INTO temp_posts (post_id, topic_id,forum_id,poster_id, post_time,post_edit_time,post_subject,post_text)
  SELECT c.post_id, c.topic_id, a.forum_id, IF(a.poster_id='-1','0',a.poster_id), a.post_time, a.post_edit_time, 
  REPLACE(b.post_subject, CONCAT(':',b.bbcode_uid),''), REPLACE(b.post_text, CONCAT(':',b.bbcode_uid),'')
  FROM phpbb_posts AS a, phpbb_posts_text AS b, temp_node AS c
  WHERE c.post_id=a.post_id AND c.post_id=b.post_id;

#
# Insert nid and tid from temp_posts into term_node
#
INSERT INTO term_node (nid,tid)
  SELECT @node_nid+topic_id,@term_data_tid+@phpbb_cat+forum_id
  FROM temp_posts;

ALTER TABLE term_node ORDER BY nid;

#
# Insert forum topics from temp_posts into node
#
INSERT INTO node (nid,type,title,uid,created,comment,changed)
  SELECT @node_nid+topic_id,'forum',post_subject,poster_id,post_time,'2',
  IF(post_edit_time<>'NULL',post_edit_time,post_time)
  FROM temp_posts;

ALTER TABLE node ORDER BY nid;

#
# Insert forum topics from temp_posts into node_revisions
#
INSERT INTO node_revisions (nid,title,uid,body)
  SELECT @node_nid+topic_id,post_subject,poster_id,post_text
  FROM temp_posts;

ALTER TABLE node_revisions ORDER BY nid;

#
# Insert nid into forum 
#
DELETE FROM forum;
INSERT INTO forum (nid,tid)
  SELECT @node_nid+topic_id,@term_data_tid+@phpbb_cat+forum_id
  FROM temp_posts;

#
# Insert comments into comments for topics from temp_posts
#
INSERT INTO comments (nid,uid,subject,comment,hostname,timestamp,users)
  SELECT @node_nid+a.topic_id,
  CASE WHEN a.poster_id='-1' THEN '0' ELSE a.poster_id END,
  REPLACE(c.post_subject, CONCAT(':',c.bbcode_uid),''),
  REPLACE(c.post_text, CONCAT(':',c.bbcode_uid),''),
  CONCAT_WS('.',CONV(SUBSTRING(a.poster_ip,1,2),16,10),
    CONV(SUBSTRING(a.poster_ip,3,2),16,10),
    CONV(SUBSTRING(a.poster_ip,5,2),16,10),
    CONV(SUBSTRING(a.poster_ip,7,2),16,10)),
  a.post_time,'a:1:{i:0;i:0;}'
  FROM phpbb_posts AS a LEFT JOIN temp_posts AS b ON a.post_id=b.post_id,phpbb_posts_text AS c
  WHERE b.post_id IS NULL AND a.post_id=c.post_id;
ALTER TABLE comments ORDER BY cid;

UPDATE comments,node
  SET comments.subject=IF(comments.subject='',
    CONCAT('Re:',node.title),comments.subject)
  WHERE comments.nid=node.nid;
  
#
# Update thread in comments
#
DROP TABLE IF EXISTS comments_tmp;
CREATE TABLE comments_tmp (
   cid int(10) NOT NULL default '0',
    nid int(10) NOT NULL default '0',
    thread int(10) NOT NULL  auto_increment,
    PRIMARY KEY  (nid,thread)
    );
    
INSERT INTO comments_tmp (cid,nid)
  SELECT cid,nid
  FROM comments
  WHERE cid>@comments_cid;

UPDATE comments,comments_tmp 
  SET comments.thread=CONCAT(CONCAT(REPEAT(9,
    LEFT(comments_tmp.thread,LENGTH(comments_tmp.thread)-1)),
    RIGHT(comments_tmp.thread,1)),'/') 
  WHERE comments.cid=comments_tmp.cid;

#
# Update history
#
#INSERT INTO history (uid, nid, timestamp)
#  SELECT a.uid, b.nid, a.timestamp
#  FROM users AS a, node AS b
#  WHERE a.uid>0 AND b.nid>@node_nid;

#
# update topic statistics 
#

INSERT INTO node_comment_statistics 
  (nid,last_comment_timestamp,last_comment_name,last_comment_uid,comment_count)
  SELECT @node_nid+pt.topic_id, pp.post_time, ppt.post_subject, pp.poster_id, 
    pt.topic_replies
  FROM node dn, phpbb_topics pt, phpbb_posts pp, phpbb_posts_text ppt
  WHERE dn.nid = @node_nid+pt.topic_id 
    AND pt.topic_last_post_id = pp.post_id 
    AND pp.post_id = ppt.post_id;

#
# Delete all temp tables
#
DROP TABLE IF EXISTS temp_posts;
DROP TABLE IF EXISTS comments_tmp;
DROP TABLE IF EXISTS temp_node;

#
# Update Drupal variables 
#
SELECT @term_data_tid:=MAX(tid) FROM term_data;
SELECT @comments_cid:=MAX(cid) FROM comments;
SELECT @node_nid:=MAX(nid) FROM node WHERE type = 'forum';
SELECT @users_uid:=MAX(uid) FROM users;

DELETE FROM sequences WHERE name="term_data_tid";
DELETE FROM sequences WHERE name="comments_cid";
DELETE FROM sequences WHERE name="node_nid";
DELETE FROM sequences WHERE name="users_uid";

INSERT INTO sequences (name,id) SELECT "term_data_tid", @term_data_tid;
INSERT INTO sequences (name,id) SELECT "comments_cid",@comments_cid;
INSERT INTO sequences (name,id) SELECT "node_nid",@node_nid;
INSERT INTO sequences (name,id) SELECT "users_uid",@users_uid;