Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
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.

Sponsored Links
Entire Thread
Subject Posted By Posted
[6.1.x] Last Post By JustDave 06/25/2002 7:03 AM
Re: Last Post By 6.1 Lisa_P 06/25/2002 8:14 AM
Re: Last Post By 6.1 JustDave 06/25/2002 8:23 AM
Re: Last Post By 6.1 JustDave 08/30/2002 4:58 AM
Re: Last Post By 6.1 JoshPet 09/11/2002 7:06 AM
Re: Last Post By 6.1 Gardener 09/11/2002 1:03 PM
Re: Last Post By 6.1 JoshPet 09/11/2002 4:54 PM
Re: Last Post By 6.1 JoshPet 09/12/2002 8:20 AM
Re: Last Post By 6.1 JustDave 09/12/2002 1:30 PM
Re: Last Post By 6.1 JustDave 09/12/2002 5:39 PM
Re: Last Post By 6.1 JoshPet 09/12/2002 6:18 PM
Re: Last Post By 6.1 JoshPet 09/12/2002 8:45 PM
Re: Last Post By 6.1 JustDave 09/12/2002 9:22 PM
Re: Last Post By 6.1 JoshPet 09/12/2002 9:57 PM
Re: Last Post By 6.1 JustDave 09/12/2002 11:08 PM
Re: Last Post By 6.1 JoshPet 09/12/2002 11:52 PM
Re: Last Post By 6.1 JoshPet 09/12/2002 11:54 PM
Re: Last Post By 6.1 JustDave 09/12/2002 11:57 PM
Re: Last Post By 6.1 JoshPet 09/13/2002 12:01 AM
Re: Last Post By 6.1 Aglavalin 09/14/2002 9:49 AM
Re: Last Post By 6.1 JustDave 09/15/2002 5:17 PM
Re: Last Post By 6.1 JoshPet 09/25/2002 2:20 AM
Re: Last Post By 6.1 JustDave 09/25/2002 2:44 AM
Re: Last Post By 6.1 msula 09/25/2002 4:14 AM
Re: Last Post By 6.1 JustDave 09/25/2002 4:19 AM
Re: Last Post By 6.1 JoshPet 09/25/2002 5:02 AM
Re: Last Post By 6.1 JoshPet 09/25/2002 6:22 AM
Re: Last Post By 6.1 omegatron 09/25/2002 7:46 PM
Re: Last Post By 6.1 JoshPet 09/25/2002 7:57 PM
Re: Last Post By 6.1 omegatron 09/26/2002 12:44 AM
Re: Last Post By 6.1 AllenAyres 10/02/2002 8:14 AM
Re: Last Post By 6.1 JoshPet 10/05/2002 4:23 AM
Re: Last Post By 6.1 JustDave 10/05/2002 5:06 AM
Re: Last Post By 6.1 AllenAyres 10/05/2002 5:19 AM
Re: Last Post By 6.1 msula 10/18/2002 3:31 AM
Re: Last Post By 6.1 JustDave 10/18/2002 3:45 AM
Re: Last Post By 6.1 msula 10/18/2002 4:39 AM
Re: Last Post By 6.1 Dave_L_dup1 10/22/2002 7:35 PM
Re: Last Post By 6.1 Rick 10/22/2002 8:01 PM
Re: Last Post By 6.1 (not a bug) JustDave 10/22/2002 9:38 PM
Re: Last Post By 6.1 (not a bug) Sat4all 11/03/2002 2:20 AM
Re: Last Post By 6.1 (not a bug) JoshPet 11/03/2002 2:29 AM
Re: Last Post By 6.1 JJS 01/01/2003 12:08 PM
Re: Last Post By 6.1 omegatron 01/01/2003 5:08 PM
Re: Last Post By 6.1 JustDave 01/01/2003 5:38 PM
Re: Last Post By 6.1 JoshPet 01/01/2003 10:33 PM
Re: Last Post By 6.1 JJS 01/03/2003 2:34 AM
Re: Last Post By 6.1 omegatron 01/03/2003 5:12 AM
Re: Last Post By 6.1 JoshPet 01/03/2003 5:42 AM
Re: Last Post By 6.1 AllenAyres 01/12/2003 11:36 PM
Re: Last Post By 6.1 JoshPet 01/13/2003 2:53 AM
Re: Last Post By 6.1 AllenAyres 01/13/2003 4:03 AM
Re: Last Post By 6.1 JoshPet 01/13/2003 6:43 AM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
• Shock Hosting
• Stable Host
• bluehost
• InterServer
Visit us on Facebook
Member Spotlight
badfrog
badfrog
somewhere on the coast of Maine
Posts: 94
Joined: March 2007
Forum Statistics
Forums63
Topics37,583
Posts293,957
Members13,826
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 4606
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 24
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
isaac 1
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20261026)