Jump to content

id (primary key) first insert 2147483650 and up?


kirkh34

Recommended Posts

hello, i am having trouble with my mysql database... my database is empty and i was getting an error for a duplicate entry everytime i wanted to insert something for the id, i saw that it was inserting 2147483650 and i found out that that was the max, so i set it to unsigned...which solved the duplicate problem, it starts at 2147483650 and continues up.... but why won't it start from 1 and increment from there? it is set to auto-increment, does anyone have an idea of what's going on here?

Link to comment
Share on other sites

Very strange ... usually with auto-increment it starts with 0 and counts up ... it shouldn't be trying to insert a larger number unless your code is telling it what to put there for some reason.

 

If the table is empty, you could always go into phpmyadmin and click on the right table, then click on SQL, and type in TRUNCATE TABLE (table name here)  without the ( ) 's of course...

 

If that doesn't solve it, try asking in the mysql section. Doesn't sound like a php issue unless again, it's because of your code.

 

Can you paste the part of the code dealing with the inserting of data?

 

 

Link to comment
Share on other sites

It sounds like something wrong with how you put the database table together.

A standard AutoInc field should start at one by default (unless you set it otherwise via SQL).  Also if you are passing an "id" to the field then it will use that ID instead of an auto-inc number.

 

Some SQL you ran on it probably screwed it up.  Delete the database and all the tables, recreate them and retry. If that is not an option then create a new database/table and try it there. If it works then it's related to some SQL you ran on it that messed it up.

Link to comment
Share on other sites

yeah i think i probably messed it up somehow myself... i was inserting random data into the tables with all kinds of different numbers...

 

jax... i tried TRUNCATE TABLE and it worked, everything is normal, how does TRUNCATE TABLE work?

Link to comment
Share on other sites

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.