kirkh34 Posted June 25, 2010 Share Posted June 25, 2010 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? Quote Link to comment Share on other sites More sharing options...
Jax2 Posted June 25, 2010 Share Posted June 25, 2010 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? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted June 25, 2010 Share Posted June 25, 2010 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. Quote Link to comment Share on other sites More sharing options...
kirkh34 Posted June 25, 2010 Author Share Posted June 25, 2010 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? Quote Link to comment 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.