Jump to content

Recommended Posts

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.