--- pager.inc.orig 2007-07-30 09:49:13.000000000 -0400 +++ pager.inc 2007-07-30 09:47:36.000000000 -0400 @@ -62,7 +62,7 @@ // Construct a count query if none was given. if (!isset($count_query)) { - $count_query = preg_replace(array('/SELECT.*?FROM /As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM ', ''), $query); + $count_query = preg_replace(array('/\s*?SELECT.*?FROM /As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM ', ''), $query); } // Convert comma-separated $page to an array, used by other functions.