Duplicate key: probably an issue like the one discussed earlier. The fix is here as well:
http://punbb.org/forums/viewtopic.php?p … 39#p104339
If you already applied that fix, try changing the code to this instead
// Have no id
if(empty($last) || $last == -1){
echo '<script type="text/javascript">window.location="index.php?page='.++$_GET['page'].'"</script>';
return;
}