Integer sent from javascript to php to mysql comes back different -
okay, im confused now.
i have app in javascript sends array of info php script, in turn saves mysql database.
the info contains unique number between 8 , 20 characters used mysql unique index , , has number incremented 1 assigned each unique number.
when send 1066998880 works checking see if row exists, adding 1 score.
but when send 100005075040249 saves mysql database 2147483647 , returns duplicate of 2147483647.
not sure im doing wrong. heres code:
javascript
$.ajax({ url: 'url', data: { unique_id: unique_id, first: first, last: last, email: email}, type: 'post', success: function(output) { 'functions'};
php
$unique_id = $_post["unique_id"]; $first = $_post["first"]; $last = $_post["last"]; $email = $_post["email"]; $count = 1; // connect server , select database. $connection = mysql_connect("$host", "$username", "$password") or die(mysql_error()); $sql = "select * `comfort_lavender`.`players` unique_id = '$unique_id'"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0){ //found mysql_query("update `comfort_lavender`.`players` set `count` = `count`+1 unique_id= '$unique_id'"); $score = mysql_query("select count `comfort_lavender`.`players` `unique_id` = '$unique_id'"); $got = mysql_fetch_array( $score ); echo $got['count']; }else{ //not found mysql_query("insert `comfort_lavender`.`players` (`unique_id`, `first`, `last`, `email`, `count`) values ('$unique_id', '$first', '$last', '$email', '1');") or die(mysql_error()); echo 1; };
2,147,483,647 largest value int (4 byte integer) can store in mysql.
change data type bigint (8 byte integer) (those can store values 9,223,372,036,854,775,807).
Comments
Post a Comment