diff --git a/include/functions.php b/include/functions.php index 725a599ea55de2b524e5a7f22d4143249efbedb1..dff951e9e12cd313f14a37197be8cf361b393d7d 100644 --- a/include/functions.php +++ b/include/functions.php @@ -844,7 +844,7 @@ function delete_post(int $post_id, int $topic_id) // Count number of replies in the topic $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$topic_id) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $db->error()); - $num_replies = $db->result($result, 0) - 1; + $num_replies = $db->result($result) - 1; // If the message we deleted is the most recent in the topic (at the end of the topic) if ($last_id == $post_id) diff --git a/include/pms_new/mdl/del.php b/include/pms_new/mdl/del.php index 270a30ffeffc28d49ba7b142ea65c6dd1f44e7cb..a26e055821b83fa41401dd634d6d1563256e2e7e 100644 --- a/include/pms_new/mdl/del.php +++ b/include/pms_new/mdl/del.php @@ -52,7 +52,7 @@ if (isset($_POST['action2'])) // Count number of replies in the topic $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'pms_new_posts WHERE topic_id='.$cur_post['tid']) or error('Unable to fetch post count', __FILE__, __LINE__, $db->error()); - $num_replies = $db->result($result, 0) - 1; + $num_replies = $db->result($result) - 1; $mquery[] = 'replies='.$num_replies; @@ -146,4 +146,3 @@ generate_pmsn_menu($pmsn_modul); query('SELECT id FROM '.$db->prefix.'pms_new_posts WHERE topic_id='.$tid.' ORDER BY id LIMIT '.$start_from.','.$pun_user['disp_posts']) or error('Unable to fetch pms_new_posts IDs', __FILE__, __LINE__, $db->error()); $post_ids = array(); -for ($i = 0;$cur_post_id = $db->result($result, $i);$i++) - $post_ids[] = $cur_post_id; +while ($row = $db->fetch_row($result)) { + $post_ids[] = $row[0]; +} $post_view_new = array(); diff --git a/moderate.php b/moderate.php index 29f02b22ce944df9da7b2563d8b62872ccd1d313..448088fcc1bb4a3383c4b741c84d4faa64d1acd2 100644 --- a/moderate.php +++ b/moderate.php @@ -526,8 +526,9 @@ if (isset($_GET['tid'])) $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id LIMIT '.$start_from.','.$pun_user['disp_posts']) or error('Unable to fetch post IDs', __FILE__, __LINE__, $db->error()); $post_ids = array(); - for ($i = 0;$cur_post_id = $db->result($result, $i);$i++) - $post_ids[] = $cur_post_id; + while ($row = $db->fetch_row($result)) { + $post_ids[] = $row[0]; + } // Retrieve the posts (and their respective poster) $result = $db->query('SELECT u.title, u.num_posts, g.g_id, g.g_user_title, p.id, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE p.id IN ('.implode(',', $post_ids).') ORDER BY p.id', true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); @@ -801,7 +802,7 @@ else if (isset($_POST['merge_topics']) || isset($_POST['merge_topics_comply'])) // Count number of replies in the topic $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$merge_to_tid) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $db->error()); - $num_replies = $db->result($result, 0) - 1; + $num_replies = $db->result($result) - 1; // Get last_post, last_post_id and last_poster $result = $db->query('SELECT posted, id, poster FROM '.$db->prefix.'posts WHERE topic_id='.$merge_to_tid.' ORDER BY id DESC LIMIT 1') or error('Unable to get last post info', __FILE__, __LINE__, $db->error()); diff --git a/userlist.php b/userlist.php index 3d3124cdd8ff907e36351ffd3848547cea7ee455..d4561b4a851334f71b6489f693bbdcf20c4033fd 100644 --- a/userlist.php +++ b/userlist.php @@ -138,8 +138,9 @@ while ($cur_group = $db->fetch_assoc($result)) $result = $db->query('SELECT u.id FROM '.$db->prefix.'users AS u WHERE u.id>1 AND u.group_id!='.PUN_UNVERIFIED.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.', u.id ASC LIMIT '.$start_from.', 50') or error('Unable to fetch user IDs', __FILE__, __LINE__, $db->error()); $user_ids = array(); -for ($i = 0;$cur_user_id = $db->result($result, $i);$i++) - $user_ids[] = $cur_user_id; +while ($row = $db->fetch_row($result)) { + $user_ids[] = $row[0]; +} if (!empty($user_ids)) { diff --git a/viewforum.php b/viewforum.php index 6ba56a9d0783ffcab4ab5ec65a89a21c4d1f20cd..af04fa2d86c45946b951326e1b42919540abd9df 100644 --- a/viewforum.php +++ b/viewforum.php @@ -186,8 +186,9 @@ if ($p == 1 && !empty($sf_array_tree[$id])) $result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.$sort_by.', id DESC LIMIT '.$start_from.', '.$pun_user['disp_topics']) or error('Unable to fetch topic IDs', __FILE__, __LINE__, $db->error()); $topic_ids = array(); -for ($i = 0; $cur_topic_id = $db->result($result, $i); $i++) - $topic_ids[] = $cur_topic_id; +while ($row = $db->fetch_row($result)) { + $topic_ids[] = $row[0]; +} // If there are topics in this forum if (!empty($topic_ids)) diff --git a/viewtopic.php b/viewtopic.php index 94d454bdd8ca6ec186146e8390a2f8cdb78f6aa4..0858e3f1e0e3fe256cdb565cd879059f526f45a1 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -326,8 +326,9 @@ $post_count = 0; // Keep track of post numbers $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY id LIMIT '.$start_from.','.$pun_user['disp_posts']) or error('Unable to fetch post IDs', __FILE__, __LINE__, $db->error()); $post_ids = array(); -for ($i = 0;$cur_post_id = $db->result($result, $i);$i++) - $post_ids[] = $cur_post_id; +while ($row = $db->fetch_row($result)) { + $post_ids[] = $row[0]; +} if (empty($post_ids)) error('The post table and topic table seem to be out of sync!', __FILE__, __LINE__);