Jump to content

Devin Powers

Clients
  • Posts

    1
  • Joined

  • Last visited

Recent Profile Visitors

693 profile views

Devin Powers's Achievements

  1. Hi - This error popped up again @The Jimmo I took a look at the source code (widgets/jimmoTopPostersPlus.php) and it seemed to resolve the problem. This error seems to occur when you're not in the top 5 and for weekly only. This means its an issue with the default case and as such the widgets rather than the AJAX folder. This was the code I found inside the if statement that checks to see if the member is logged in. $you = \IPS\Db::i()->select( 'author_id, COUNT(author_id) as posts', 'forums_posts', array( 'author_id =' . \IPS\Member::loggedIn()->member_id . ' AND post_date>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1W' ) )->getTimestamp() ), '', '', NULL)->join( 'core_members', 'forums_posts.author_id=core_members.member_id' ); I changed the code to the following: $myPosts = \IPS\Db::i()->select( 'author_id, COUNT(author_id) as posts', 'forums_posts', array( 'author_id =? AND post_date>?', \IPS\Member::loggedIn()->member_id, \IPS\DateTime::create()->sub( new \DateInterval( 'P1W' ) )->getTimestamp()) , '', '', array('author_id'))->join( 'core_members', 'forums_posts.author_id=core_members.member_id' ); if (count($myPosts > 0)) { foreach ($myPosts as $col) { $y = $col['posts']; } $you = $y; } else { $you = 0; } To explain: I've changed it so both parameters in the where clause are parameterized and I've made it group it by author_id. Then I've checked to see if there is a result (a new member with 0 posts wouldn't have any results returned). Then I've just selected it. A neater way would probably be the try-catch-block using the ->first() method where if it fails you assign $you to 0, but this was just a quick dirty fix for me. Hope this helps some other people ? Cheers.
×
×
  • Create New...