There are some cases where the "last post by" information isn't being updated when a reply is deleted. Below is what I believe is the fix. Let me know otherwise..

In the instructions change this:
code:
Step 7.
In your deletepost.php script find this:
// ------------------------------------------------------------
// We also need to decrease the number of replies in this topic
$query = "
UPDATE w3t_Posts
SET B_Replies = B_Replies -1
WHERE B_Number = '$Main'
";
$dbh -> do_query($query);
and change it to this:
$query = "
SELECT B_Number,B_Username,B_Approved
FROM w3t_Posts
WHERE B_Board = '$Board_q'
AND B_Approved = 'yes'
AND B_Main = '$Main'
AND B_Main <> B_Number
ORDER BY B_Number DESC
LIMIT 1
";
$lastPost = $dbh -> do_query($query);
list($lastNumber,$lastName,$lastApproved) = $dbh -> fetch_array($lastPost);
$lastName = addslashes($lastName);
// ------------------------------------------------------------
// We also need to decrease the number of replies in this topic
$query = "
UPDATE w3t_Posts
SET B_Replies = B_Replies -1,
B_Last_Number = '$lastNumber',
B_Last_Name = '$lastName',
B_Last_Approved = '$lastApproved'
WHERE B_Number = '$Main'
";
$dbh -> do_query($query);
to this:
code:
Step 7.
In your deletepost.php script find this:
// ------------------------------------------------------------
// We also need to decrease the number of replies in this topic
$query = "
UPDATE w3t_Posts
SET B_Replies = B_Replies -1
WHERE B_Number = '$Main'
";
$dbh -> do_query($query);
and change it to this:
$query = "
SELECT B_Main,B_Number,B_Username,B_Approved
FROM w3t_Posts
WHERE B_Board = '$Board_q'
AND B_Approved = 'yes'
AND B_Main = '$Main'
ORDER BY B_Number DESC
LIMIT 1
";
$lastPost = $dbh -> do_query($query);
list($lastMain,$lastNumber,$lastName,$lastApproved) = $dbh -> fetch_array($lastPost);
$lastName = addslashes($lastName);
if ($lastMain == $lastNumber) {
// It's the main post therefore no replies left, right?
$lastNumber = "";
$lastName = "";
$lastApproved = "";
}
// ------------------------------------------------------------
// We also need to decrease the number of replies in this topic
$query = "
UPDATE w3t_Posts
SET B_Replies = B_Replies -1,
B_Last_Number = '$lastNumber',
B_Last_Name = '$lastName',
B_Last_Approved = '$lastApproved'
WHERE B_Number = '$Main'
";
$dbh -> do_query($query);
This may or may not be the cure but it is fixing a flaw in the code none the less.
