2

I'm doing a Facebook Connect integration. I use the Facebook PHP library to get the uid, like:

$facebook = new Facebook($api_key, $secret); $fb_user = $facebook->require_login();

$fbuser is a 16-character long bigint, such as 1000002949493949

However, when I insert this value into MySQL, it only inserts 2949493949.

So later when I try to match the uid to the one stored in my database with 1000002949493949 it doesn't match because the database is returning 2949493949.

The uid field in my database is a bigint with a length of 20. It was originally an int, but I altered it when I started encountering the new, longer uids.

Any idea what I need to do to store the uid correctly?

rgettman
  • 176,041
  • 30
  • 275
  • 357
hiester
  • 178
  • 4
  • 12

3 Answers3

5

When storing the fb_uid in the db, you should be storing it as a BIGINT ( for mysql )

mailtrak
  • 51
  • 1
  • 1
4

You need to make sure you're using a 64 bit integer in PHP as well. Can you post the PHP portion of the code that stores the information?

I would suggest trying to keep the id as a string and not an integer if you're using a 32 bit version of PHP.

Mike Sherov
  • 13,277
  • 8
  • 41
  • 62
0

the easiest way out would be to store the uid values from facebook as a varchar. if u only have to query the mysql db to get the uid value, then this is the easiest way out.

amit
  • 10,133
  • 22
  • 72
  • 121
  • there is no reason to use VARCHAR when a BIGINT has much smaller storage requirements: BIGINT is 8 bytes vs VARCHAR is 17 bytes in this case. http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html The issue here isn't the storage in MySQL, the issue is how the value is carried around in PHP before it gets to MySQL. – Mike Sherov Feb 10 '10 at 18:10
  • True, but can BIGINT handle the uid in whole? – aalaap Jul 22 '11 at 13:02