0

Here is the code that sends the data to the DB:

$sql = "INSERT INTO facebook (`artist_id`, `facebook_id`, `likes`, `talking_about_count` , `facebook_username`)VALUES ('" . $artist_id . "','" . $artist_object->id . "','" . $artist_object->likes . "','" . $artist_object->talking_about_count . "','" . $artist_object->username . "')";

echo "Adding " .  $artist_object->username . " to Database";

echo '<br />' . $artist_object->id . '<br />';
var_dump($sql);

Here is what is echoed to the page:

Adding tiesto to Database
12626353545
string(160) "INSERT INTO facebook (`artist_id`, `facebook_id`, `likes`, `talking_about_count` , `facebook_username`) VALUES ('5','12626353545','16868620','428952','tiesto')"

Here is what is reflected in the DB for user #5

artist_id : 5
facebook_id : 2147483647
likes : 16868620
talking_about_count : 428952
facebook_username : tiesto

What is causing the DB to change the number for the facebook ID? I originally thought it might have something to do with the length of the INT field, but I've set it to 30, and made sure the encoding is set correctly. Kinda stumped on this one?

5
  • 3
    int(30) does not make sense .. u need to use bigint Commented Mar 20, 2014 at 7:08
  • @Xenology provide your table structure. Commented Mar 20, 2014 at 7:10
  • 1
    possible duplicate of No matter what I do the same value is being stored in MySQL table field Commented Mar 20, 2014 at 7:11
  • 1
    you are exceeding the limit for the integer value for facebook_id field. use bigint or save it as an (n)varchar string. Commented Mar 20, 2014 at 7:11
  • you are trying to insert string in int type column try without single quotes in the id column ," . $artist_object->id . ", Commented Mar 20, 2014 at 7:12

2 Answers 2

3

Your value is beyond limit of INT. INT(30) is not possible.

Please refer MySql Page

Sign up to request clarification or add additional context in comments.

1 Comment

Awarding points here, I was not aware that there were limits to the size of the integers in MySQL but it makes sense now. Thank you for providing the resource.
2

Change int to bigint like this.

ALTER TABLE `facebook` MODIFY COLUMN `facebook_id`  bigint NOT NULL;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.