Index: contrib/fb_friend.module
===================================================================
--- contrib/fb_friend.module	(revision 3969)
+++ contrib/fb_friend.module	(working copy)
@@ -89,7 +89,7 @@

   if ($fbu = fb_facebook_user()) {
     // Confirm invitation is in the fb_friend table.
-    $where = array('fbf.status > %d', 'fbf.fbu_target = %d');
+    $where = array('fbf.status > %d', 'fbf.fbu_target = %s');
     $args = array(0, $fbu);
     foreach (array(
                'ref_id' => '%s',
@@ -441,7 +441,7 @@
   $accept_url = url($params['accept_path'], array('absolute' => TRUE, 'fb_canvas' => fb_is_canvas()));

   // Learn which users to exclude
-  $result = db_query("SELECT fbu_target FROM {fb_friend} WHERE module='%s' AND fbu_actor=%d AND ref_id=%d",
+  $result = db_query("SELECT fbu_target FROM {fb_friend} WHERE module='%s' AND fbu_actor=%s AND ref_id=%d",
                      $params['module'], fb_facebook_user(), $params['ref_id']);
   while ($data = db_fetch_object($result)) {
     $params['exclude_ids'][] = $data->fbu_target;
@@ -547,8 +547,9 @@

 function fb_friend_query_records($args) {
   $types = array(
-    'fbu_actor' => '%d',
-    'fbu_target' => '%d',
+    // Note, use %s for big ints
+    'fbu_actor' => '%s',
+    'fbu_target' => '%s',
     'ref_id' => '%d',
     'module' => "'%s'",
     'label' => "'%s'",
Index: contrib/fb_user_app.module
===================================================================
--- contrib/fb_user_app.module	(revision 3969)
+++ contrib/fb_user_app.module	(working copy)
@@ -70,7 +70,7 @@
     elseif ($event_type == FB_APP_EVENT_POST_REMOVE) {
       $fbu = fb_settings(FB_SETTINGS_FBU);
       // User has removed the app from their account.
-      db_query("DELETE FROM {fb_user_app} WHERE apikey='%s' AND fbu=%d",
+      db_query("DELETE FROM {fb_user_app} WHERE apikey='%s' AND fbu=%s",
                $fb_app->apikey, $fbu);
     }
   }
@@ -81,7 +81,7 @@
     // to provide it, depending on whether the user has logged in, and whether
     // the session has expired.
     $fbu = $data['fbu'];
-    $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey = '%s' and fbu = %d", $fb_app->apikey, $fbu);
+    $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey = '%s' and fbu = %s", $fb_app->apikey, $fbu);
     $data = db_fetch_object($result);

     if ($data && $data->session_key)
@@ -113,7 +113,7 @@
   if ($op == 'delete') {
     // Given the uid, fetch the fbu so that we can delete
     $fbu = fb_get_fbu($account->uid);
-    db_query('DELETE FROM {fb_user_app} WHERE fbu=%d', $fbu);
+    db_query('DELETE FROM {fb_user_app} WHERE fbu=%s', $fbu);
   }
 }

@@ -166,7 +166,7 @@
   if ((variable_get(FB_USER_APP_VAR_TRACK_USERS, TRUE) && $fb_user_type = "user") ||
       (variable_get(FB_USER_APP_VAR_TRACK_PAGES, TRUE) && $fb_user_type = "page")) {

-    $result = db_query("UPDATE {fb_user_app} SET time_access=%d, session_key='%s', session_key_expires=%d, user_type='%s' WHERE apikey='%s' AND fbu=%d",
+    $result = db_query("UPDATE {fb_user_app} SET time_access=%d, session_key='%s', session_key_expires=%d, user_type='%s' WHERE apikey='%s' AND fbu=%s",
                        time(),
                        $access_token, $expires,
                        $fb_user_type,
@@ -177,7 +177,7 @@
       // The row for this user was never inserted, or it was deleted, or the times were the same.
       if ($fbu) {
         // First make sure it was not just the same time
-        $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey='%s' AND fbu=%d",
+        $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey='%s' AND fbu=%s",
                            $fb_app->apikey,
                            $fbu);
         if (!db_fetch_object($result)) {
@@ -185,7 +185,7 @@
           $info = fb_users_getInfo(array($fbu), $fb);
           $data = $info[0];
           $fb_user_type = "user";
-          $result = db_query("INSERT INTO {fb_user_app} (apikey, fbu, added, user_type, session_key, session_key_expires, time_access, proxied_email, time_cron) VALUES ('%s', %d, %d, '%s', '%s', %d, %d, '%s', %d)",
+          $result = db_query("INSERT INTO {fb_user_app} (apikey, fbu, added, user_type, session_key, session_key_expires, time_access, proxied_email, time_cron) VALUES ('%s', %s, %d, '%s', '%s', %d, %d, '%s', %d)",
                              $fb_app->apikey, $fbu,
                              $data['is_app_user'],
                              $fb_user_type,
@@ -210,7 +210,7 @@
  */
 function fb_user_app_get_proxied_email($fbu, $fb_app) {
   // Try to learn from local database
-  $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey='%s' AND fbu=%d",
+  $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey='%s' AND fbu=%s",
                      $fb_app->apikey,
                      $fbu);
   if ($data = db_fetch_object($result)) {
@@ -225,7 +225,7 @@
     $mail = $data['proxied_email'];
     if ($mail && variable_get(FB_USER_APP_VAR_TRACK_USERS, TRUE)) {
       // Store locally.
-      $result = db_query("UPDATE {fb_user_app} SET proxied_email='%s' WHERE apikey='%s' AND fbu=%d",
+      $result = db_query("UPDATE {fb_user_app} SET proxied_email='%s' WHERE apikey='%s' AND fbu=%s",
                          $mail, $fb_app->apikey, $fbu);
     }
   }
Index: fb_user.module
===================================================================
--- fb_user.module	(revision 3970)
+++ fb_user.module	(working copy)
@@ -807,11 +807,13 @@
   if ($fbu &&
       $account->uid != 0) {

+    // Note, use %s for bigint field fbu.
+
     // Delete any pre-existing mapping that might exist for this local uid or fbu.
-    db_query("DELETE FROM {fb_user} WHERE uid=%d OR fbu=%d", $account->uid, $fbu);
+    db_query("DELETE FROM {fb_user} WHERE uid=%d OR fbu=%s", $account->uid, $fbu);

     // Create the new mapping.
-    db_query("INSERT INTO {fb_user} (uid, fbu) VALUES (%d, %d)", $account->uid, $fbu);
+    db_query("INSERT INTO {fb_user} (uid, fbu) VALUES (%d, %s)", $account->uid, $fbu);

     if (fb_verbose()) {
       watchdog('fb_user', 'Using fb_user to associate user !user with facebook user id %fbu.',
@@ -940,7 +942,7 @@
 }

 function _fb_user_get_uid($fbu, $fb_app = NULL) {
-  $result = db_result(db_query("SELECT uid FROM {fb_user} WHERE fbu=%d", array(
+  $result = db_result(db_query("SELECT uid FROM {fb_user} WHERE fbu=%s", array(
                                  $fbu,
                                )));
   return $result;
