Title: SQLite: unexpected T_FUNCTION
Last modified: August 22, 2016

---

# SQLite: unexpected T_FUNCTION

 *  [ech3](https://wordpress.org/support/users/ech3/)
 * (@ech3)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sqlite-unexpected-t_function/)
 * When I upgraded to the latest SQLite, I found the following error in my logs:
 * [Wed Sep 10 11:29:53 2014] [error] [client [redacted]] PHP Parse error: syntax
   error, unexpected T_FUNCTION in [redacted]/wordpress/wp-content/plugins/sqlite-
   integration/query.class.php on line 769, referer: [redacted]/wordpress/wp-admin/
   update.php?action=update-selected&plugins=sqlite-integration%2Fsqlite-integration.
   php&_wpnonce=42a8126bb2
    [Wed Sep 10 11:30:06 2014] [error] [client [redacted]]
   PHP Parse error: syntax error, unexpected T_FUNCTION in [redacted]/wordpress/
   wp-content/plugins/sqlite-integration/query.class.php on line 769
 * I am assuming it is because I am on PHP Version 5.2.4.
 * [https://wordpress.org/plugins/sqlite-integration/](https://wordpress.org/plugins/sqlite-integration/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [kjmtsh](https://wordpress.org/support/users/kjmtsh/)
 * (@kjmtsh)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sqlite-unexpected-t_function/#post-5279158)
 * Thank you for the report, ech3.
 * Yes, your assumption is right. I seem to slip in the code PHP ver 5.2.x doesn’t
   execute. Could you edit query.class.php, please?
 * Open the file with your favorite editor and go down to the line 769. You will
   find the code like below.
 *     ```
       $compare = function($a, $b) {
                       global flipped;
                       return flipped[$a->ID] - flipped[$b-ID];
                   };
                   usort($results, $compare);
               }
               $wpdb->dbh->pre_ordered_results = $results;
           }
       }
       ```
   
 * Comment out the four lines (add two backslashes for each line), change the usort()’
   s arguments and add a new function at the end of it, just like below:
 *     ```
       // $compare = function($a, $b) {
                   //    global flipped;
                   //    return flipped[$a->ID] - flipped[$b-ID];
                   // };
                   usort($results, array($this, 'orderby_callback'));
               }
               $wpdb->dbh->pre_ordered_results = $results;
           }
       }
       private function orderby_callback($a, $b) {
           global flipped;
           return flipped[$a->ID] - $flipped[$b->ID];
       }
       ```
   
 * With this change, PHP 5.2.x will execute without errors.
 * I’ll commit the change for the next release, but the date is uncertain. I hope
   this will help you.
 *  Thread Starter [ech3](https://wordpress.org/support/users/ech3/)
 * (@ech3)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sqlite-unexpected-t_function/#post-5279163)
 * I ended up having to add a dollar sign before the orderby_callback function’s
   flipped variable in a couple of places to get it to work. Below is the diff I
   used.
 * [Edit – Reversed the diff to the correct direction]
 *     ```
       --- query.class.php.orig        2014-09-12 06:21:17.802511000 -0400
       +++ query.class.php     2014-09-12 06:11:27.503756000 -0400
       @@ -766,15 +766,20 @@
                                       $_wpdb = new PDODB();
                                       $results = $_wpdb->get_results($query);
                                       $_wpdb = null;
       -                               $compare = function($a, $b) {
       -                                       global $flipped;
       -                                       return $flipped[$a->ID] - $flipped[$b->ID];
       -                               };
       -                               usort($results, $compare);
       +                               //$compare = function($a, $b) {
       +                                //global $flipped;
       +                                //return $flipped[$a->ID] - $flipped[$b->ID];
       +                               //};
       +                               //usort($results, $compare);
       +                                usort($results, array($this, 'orderby_callback'));
                               }
                               $wpdb->dbh->pre_ordered_results = $results;
                       }
               }
       +       private function orderby_callback($a, $b) {
       +               global $flipped;
       +               return $flipped[$a->ID] - $flipped[$b->ID];
       +       }
               /**
                * Method to avoid DELETE with JOIN statement.
                *
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘SQLite: unexpected T_FUNCTION’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/sqlite-integration.svg)
 * [SQLite Integration](https://wordpress.org/plugins/sqlite-integration/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sqlite-integration/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sqlite-integration/)
 * [Active Topics](https://wordpress.org/support/plugin/sqlite-integration/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sqlite-integration/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sqlite-integration/reviews/)

## Tags

 * [sqlite](https://wordpress.org/support/topic-tag/sqlite/)
 * [T_FUNCTION](https://wordpress.org/support/topic-tag/t_function/)

 * 2 replies
 * 2 participants
 * Last reply from: [ech3](https://wordpress.org/support/users/ech3/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/sqlite-unexpected-t_function/#post-5279163)
 * Status: not resolved