[BUG FIX] - Members_List Invalid page number SQL error
by coRpSE
Okay, working on someones site and checking error logs, I found they had a bunch of errors I have never seen before. After looking into it. I had written up a fix for this issue.
What was happening:
When someone went to the members list module and just say, tried visiting a page that didn't exist. It would throw an error. So what I did was wrote some code that counts the total number of valid users in the database, excluding anonymous users and those with a user level of -1. It then calculates how many pages are needed to display all users based on the number of items per page. By comparing the requested page number to the maximum possible pages, it prevents invalid page numbers that would cause SQL errors. This ensures the query always uses a safe and valid range for pagination.
To fix this, download the attached file and upload it to your site, keeping the file structure and overwrite your current file. To test to see it working, just go to your site, and put at the end of your URL this:
/modules.php?name=Members_List&page=9999
If you don't see an error, you did it right.
What was happening:
When someone went to the members list module and just say, tried visiting a page that didn't exist. It would throw an error. So what I did was wrote some code that counts the total number of valid users in the database, excluding anonymous users and those with a user level of -1. It then calculates how many pages are needed to display all users based on the number of items per page. By comparing the requested page number to the maximum possible pages, it prevents invalid page numbers that would cause SQL errors. This ensures the query always uses a safe and valid range for pagination.
To fix this, download the attached file and upload it to your site, keeping the file structure and overwrite your current file. To test to see it working, just go to your site, and put at the end of your URL this:
/modules.php?name=Members_List&page=9999
If you don't see an error, you did it right.
Great, work for me....
Nice!, Worked for me also.

