2147483648 php/mysql problem

Busy's picture

He has: 6,151 posts

Joined: May 2001

I did a search on good ole google and even looked at php and mysql sites but nothing in plain english explains whats going on.

I'm inserting stuff into database, even if I leave the primary field blank its inserting 2147483648, all I can found out from the search was it's the maximum limit.
In phpmyadmin the "Next Autoindex" shows 2147483648

at the moment the db table is: auc_id int(11) UNSIGNED Not null auto_increment
primary key unique

rewritten the simple insert many times (lack of sleep, lack of coffee and bad haircut), the latest is

$query = "INSERT INTO table_name
(auc_id, user_id, title, description, ....)
VALUES
('$aucid', '$user_id', '$title', '$description', ...)

even if i remove the auc_id and '$aucid', the $auc_id becomes 2147483648, even if I give $aucid a value (doesn't have one by default) it still inserts 2147483648

the value of auc_id in the db should be a value of 100024 or whatever next value is

any ideas?

druagord's picture

He has: 335 posts

Joined: May 2003

if you can the easy way to set back the next autoindex to 0 is to use
"TRUNCATE TABLE yourtable" if you have mysql >3.23.32 between 3.23.28 and 3.23.32 use "TRUNCATE yourtable" CAREFUL this will also empty the table

if you can't empty the table you have to use "ALTER TABLE tbl_name AUTO_INCREMENT = 100" replace 100 to whatever value you need

IF , ELSE , WHILE isn't that what life is all about

Busy's picture

He has: 6,151 posts

Joined: May 2001

I think I've found the problem, I have so many included files and functions it seems I missed a generate id function, since I have 3 diferent pages calling up similar scripts and using the same db table the generate id function was generating an encrypted value (massive number) and inserting it when I was testing the other scripts.

So hopefully this was the problem
also changed the table from int to mediumint

and the ALTER table worked too, thanks druagord

They have: 20 posts

Joined: Oct 2003

This comes from reading a NULL from a database into a number field. A NULL is not the same as a 0, so it is interpreted as 2147483648.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.