views:

317

answers:

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 uid to the one stored in my database 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?

+2  A: 

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
A: 

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
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.htmlThe 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

related questions