PDA

View Full Version : Lastpost code


Boofo
03-15-2003, 01:13 AM
Can anyone please tell me what would make the following code sometimes give an "thread not specified" error and other times work great? If I update thread counters and then forum counters in the Admin CP, this code works fine. but sometimes if a new message is placed in the thread or a message is moved or deleted, then I start getting the error again on some forums and have to reset the counters to make it work.

// goto newest thread
if ($goto=="newthread") {
if (isset($forumid) and $forumid!=0) {
$foruminfo=verifyid("forum",$forumid,1,1);
$forumid=$foruminfo['forumid'];
$lastthread=$DB_site->query_first("SELECT threadid FROM post WHERE username='".addslashes(htmlspecialchars($foruminfo[lastposter]))."' AND dateline='$foruminfo[lastpost]'");
// $lastthread=$DB_site->fetch_array($DB_site->query("SELECT threadid FROM post WHERE username='".addslashes($foruminfo[lastposter])."' AND dateline='$foruminfo[lastpost]'"));
header("Location: showthread.php?s=$session[sessionhash]&threadid=$lastthread[threadid]");
exit;
}
}

and here is the line i use to call the post title

<a href="showthread.php?s=$session[sessionhash]&goto=newthread&forumid=$forum[forumid]" title="Go to first post">$forum[lastthread]</a>

Erwin
03-15-2003, 01:18 AM
It's a known bug that I think was fixed with the latest version of the last title hack released - otherwise, it's a matter of adding pieces of code to the postings.php file etc. manually - instructions are in that thread from memory.

This is because the lastpost column in the table needs to be updated, and you need to do this with other PHP files which affects the lastpost variable.

Boofo
03-15-2003, 01:20 AM
I have the latest version installed and I couldn't find anything about it in the thread. Can you lead me to it or let me know what I need to do to fix it, please?

Edit: No fix is in the thread that I haven't already tried. I just re-read the whole thread. The only change is using Teck's newthread code instead of PPN's. Will see if that changes anything. Thanks for all the help. :p

You can close this thread now.