as i told ya in my pm your part of editpost.php is wrong:
PHP Code:
$lastpost = $DB_site->query_first("SELECT * FROM post WHERE threadid = '$threadid' ORDER BY postid DESC");
because the newest post is always the last post of a thread

you must use a query one post before:
PHP Code:
$lastpost = $DB_site->query_first("SELECT * FROM post WHERE threadid = '$threadid' AND postid<$postid ORDER BY postid DESC");
i think that should be right...