Beauford Posted March 10, 2009 Share Posted March 10, 2009 I have a database with many tables and in several of them I have a number field designated as binint, size(20). Perieodically I am getting the maximum allowed for this field inserted, which is (18446744073709551616) instead what should be inserted, or updated. Why is this happening? I am just looking for general information or assumptions and to see if anyone else has had this issue and what were the circumstances. I have posted a snippet of code below, which may or may not help. The part where it updates, UPDATE users SET money=money-1000000 seems to where the problem is as it is the only thing being set in the field from this script, but this one - UPDATE userstats SET tmoney=tmoney-1000000 - which is updated after the first one, works fine. $name=mysql_real_escape_string($_POST['name']); $description=mysql_real_escape_string($_POST['description']); $db->query("INSERT INTO gangs VALUES('','$name','$description','{$_POST['gangLOGO']}','{$_POST['prefix']}',0,0,0,0,0,$userid, 5,1,'','',unix_timestamp(),1)"); $i=$db->insert_id(); $db->query("UPDATE users SET gang=$i, gangdate=unix_timestamp(), money=money-1000000 where userid=$userid"); $db->query("UPDATE userstats SET tmoney=tmoney-1000000 where userid=$userid"); $db->query("INSERT INTO forums VALUES('','$name', '$description', 0, 0, 0, 0, 'No Posts', 'gang', {$i}, 0)"); Any help or suggestions is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/148784-insertupdate-problem-max-value-being-inserted/ Share on other sites More sharing options...
aschk Posted March 10, 2009 Share Posted March 10, 2009 Which of those statement's is causing the problem, and which field? Also when you do inserts specify the fields you're going to be inserting into (it makes it clearer). e.g. INSERT INTO table1(field1, field2) VALUES(value1, value2) This also avoids the issue where you have to supply '' for your primary key (which i'm surprised hasn't errored yet). Quote Link to comment https://forums.phpfreaks.com/topic/148784-insertupdate-problem-max-value-being-inserted/#findComment-781264 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.