2006-01-13, 06:07 AM
Sorry, but this is bugging me and I have to ask. I can't figure out why this code is in this order...
Eleven full lines of code assuming that $pid was valid (and that the query returned something), and THEN you get around to checking it? WTF?
(That example is from editpost, but a similar thing is done in newthread and newreply)
PHP Code:
$pid = intval($mybb->input['pid']);
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."posts WHERE pid='$pid'");
$post = $db->fetch_array($query);
$tid = $post['tid'];
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads WHERE tid='$tid'");
$thread = $db->fetch_array($query);
$thread['subject'] = htmlspecialchars_uni($thread['subject']);
$fid = $thread['fid'];
makeforumnav($fid);
addnav($thread['subject'], "showthread.php?tid=$thread[tid]");
addnav($lang->nav_editpost);
$forumpermissions = forum_permissions($fid);
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."forums WHERE fid='$fid'");
$forum = $db->fetch_array($query);
if(!$post['pid'])
{
����error($lang->error_invalidpost);
}
(That example is from editpost, but a similar thing is done in newthread and newreply)