Title: Errors in debug.log
Last modified: August 30, 2016

---

# Errors in debug.log

 *  Resolved [Garrett Hyder](https://wordpress.org/support/users/garrett-eclipse/)
 * (@garrett-eclipse)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/errors-in-debuglog/)
 * Hello,
 * I was hoping you could assist me in clearing up these errors I’m getting;
 *     ```
       [08-Sep-2015 20:57:42 UTC] PHP Notice:  Undefined index: pagination in /home/ljlee/public_html/wp-content/plugins/bp-sticky-groups/bp-sticky-groups.php on line 327
       [08-Sep-2015 20:57:42 UTC] PHP Notice:  Undefined offset: 1 in /home/ljlee/public_html/wp-content/plugins/bp-sticky-groups/bp-sticky-groups.php on line 330
       [08-Sep-2015 20:57:42 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 for query SELECT DISTINCT g.id, g.*, gm1.meta_value AS total_member_count, gm2.meta_value AS last_activity, 1 as sticky  FROM wp_bp_groups_groupmeta gm1, wp_bp_groups_groupmeta gm2, wp_bp_groups_groupmeta gms,  wp_bp_groups g WHERE  g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.id = gms.group_id AND gms.meta_key = 'sticky'  AND g.status != 'hidden' ORDER BY g.name ASC LIMIT  made by include('wp-admin/edit-form-advanced.php'), do_meta_boxes, call_user_func, custom_add_meta_box->meta_box_callback, BP_Groups_Group::get, apply_filters('bp_groups_get_paged_groups_sql'), call_user_func_array, BP_Sticky_Groups->alter_bp_groups_query, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query
       ```
   
 * Much appreciated,
    Cheers
 * [https://wordpress.org/plugins/bp-sticky-groups/](https://wordpress.org/plugins/bp-sticky-groups/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Garrett Hyder](https://wordpress.org/support/users/garrett-eclipse/)
 * (@garrett-eclipse)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/errors-in-debuglog/#post-6529224)
 * I’ve been able to resolve this by tweaking the code to anticipate the possibility
   that there isn’t a pagination set, which occurs if you are doing a custom groups
   loop to get all groups rather than them in chunks.
 * Firstly on line 327 I wrapped this block of code in an if check.
 *     ```
       $offset = explode( ',', str_replace( array( 'LIMIT', ' '), '', $sql_args['pagination'] ) );
       $offset = array_map( 'intval', $offset);
   
       $sticky_sql['pagination'] = "LIMIT {$offset[1]}";
       ```
   
 * Like so;
 *     ```
       if ( array_key_exists('pagination', $sql_args) && ! empty($sql_args['pagination']) ) {
       	$offset = explode( ',', str_replace( array( 'LIMIT', ' '), '', $sql_args['pagination'] ) );
       	$offset = array_map( 'intval', $offset);
   
       	$sticky_sql['pagination'] = "LIMIT {$offset[1]}";
       }
       ```
   
 * Then as offset won’t exist we want to wrap the following in another conditional
   on line 339;
 *     ```
       if( count( $sticky_group ) == $offset[1] && 0 == $offset[0] ) {
       	return join( ' ', (array) $sticky_sql );
       }
       ```
   
 * Like so;
 *     ```
       if ( ! empty( $offset ) ) {
       	if( count( $sticky_group ) == $offset[1] && 0 == $offset[0] ) {
       		return join( ' ', (array) $sticky_sql );
       	}
       }
       ```
   
 * And finally we need to wrap the setting of $sql_args[‘pagination’] in a conditional
   on line 370;
 *     ```
       if( 0 == $offset[0] )
       	$sql_args['pagination'] = 'LIMIT 0, ' . intval( $offset[1] - count( $this->stickies ) );
   
       else
       	$sql_args['pagination'] = 'LIMIT ' . intval( $offset[0] - count( $this->stickies ) ) . ', '. $offset[1] ;
       ```
   
 * Like so;
 *     ```
       if ( empty( $offset ) ) {
       	if( 0 == $offset[0] )
       		$sql_args['pagination'] = 'LIMIT 0, ' . intval( $offset[1] - count( $this->stickies ) );
   
       	else
       		$sql_args['pagination'] = 'LIMIT ' . intval( $offset[0] - count( $this->stickies ) ) . ', '. $offset[1] ;
       }
       ```
   
 * Once you’ve made these modifications you won’t run into warnings due to not using
   pagination on groups.
 * Resolving,
    Cheers P.S. Is there a repo or anyway to get this updated for the
   plugin. Thanks

Viewing 1 replies (of 1 total)

The topic ‘Errors in debug.log’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/bp-sticky-groups_334350.svg)
 * [BP Sticky Groups](https://wordpress.org/plugins/bp-sticky-groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bp-sticky-groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bp-sticky-groups/)
 * [Active Topics](https://wordpress.org/support/plugin/bp-sticky-groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bp-sticky-groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bp-sticky-groups/reviews/)

## Tags

 * [Database Error](https://wordpress.org/support/topic-tag/database-error/)
 * [errors](https://wordpress.org/support/topic-tag/errors/)
 * [undefined index](https://wordpress.org/support/topic-tag/undefined-index/)
 * [undefined offset](https://wordpress.org/support/topic-tag/undefined-offset/)

 * 1 reply
 * 1 participant
 * Last reply from: [Garrett Hyder](https://wordpress.org/support/users/garrett-eclipse/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/errors-in-debuglog/#post-6529224)
 * Status: resolved