ccrevcypsys Posted February 8, 2008 Share Posted February 8, 2008 I am working on this website that some dumb ass made. And i am makeing it to where you can edit a table called `courses` and i am trying to add an main `id` column because the dumb ass who made it didnt put one. And now everytime i do this i get this error Error SQL query: ALTER TABLE `courses` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT MySQL said: Documentation #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key And i look up on mysql documentation website and it just repeated the same thing couldn't find a way to fix this... Can someone please help me? Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/ Share on other sites More sharing options...
Dada78 Posted February 8, 2008 Share Posted February 8, 2008 This mean that their is already a field set to auto-increment and set as primary. You just need to find which one that is and unset it and set it to the field you are needing in this case is id. Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462183 Share on other sites More sharing options...
ccrevcypsys Posted February 8, 2008 Author Share Posted February 8, 2008 Ya i know that and i checked for it but cant seem to find it.. Here is the table Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462195 Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 There is already a field named "Id" in the table. Just make that one the autoincrement field. Ken Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462203 Share on other sites More sharing options...
ccrevcypsys Posted February 8, 2008 Author Share Posted February 8, 2008 thats the one im trying to change... i get the same error everytime i try Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462206 Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 No, you're trying to "Add" it again, not change it. But since you're using phpmyadmin, just use it to change the field. Ken Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462211 Share on other sites More sharing options...
phpSensei Posted February 8, 2008 Share Posted February 8, 2008 Make the "Extra:" for ID Auto_increment. Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462213 Share on other sites More sharing options...
ccrevcypsys Posted February 8, 2008 Author Share Posted February 8, 2008 Ok i get this error every time i do that... Error SQL query: ALTER TABLE `courses` CHANGE `id` `id` INT( 11 ) NULL AUTO_INCREMENT MySQL said: Documentation #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key then i try to define it as a key and get this one Error SQL query: ALTER TABLE `courses` ADD PRIMARY KEY ( `id` ) MySQL said: Documentation #1062 - Duplicate entry '0' for key 1 Then everytime i delete it and try again i get the same 2 damn errors! This is very frustrating Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462220 Share on other sites More sharing options...
phpSensei Posted February 8, 2008 Share Posted February 8, 2008 SHow us the bottom of the table, it usually says which field is already a UNIQUE KEY or Auto_increment. Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462221 Share on other sites More sharing options...
ccrevcypsys Posted February 8, 2008 Author Share Posted February 8, 2008 Indexes: Documentation Keyname-----------Type--------Cardinality------Action---Field DrKey--------------INDEX-------253-------Edit----Drop----DrKey EventKey----------INDEX--------23 -------Edit----Drop----EventKey this is all that resides at the bottom Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462225 Share on other sites More sharing options...
phpSensei Posted February 8, 2008 Share Posted February 8, 2008 Okay first of all, dont use INDEX if you dont know what it means please. Undo those changes, they dont need to me indexes. DrKey--------------INDEX-------253-------Edit----Drop----DrKey EventKey----------INDEX--------23 -------Edit----Drop----EventKey only 1 INDEX per table is good, and it should be the auto_increment. Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462226 Share on other sites More sharing options...
ccrevcypsys Posted February 8, 2008 Author Share Posted February 8, 2008 I didnt put them on index's they where already on index. And i did remove them and tried to make it a key again but nope it did the same thing again... Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462227 Share on other sites More sharing options...
phpSensei Posted February 8, 2008 Share Posted February 8, 2008 I didnt put them on index's they where already on index. And i did remove them and tried to make it a key again but nope it did the same thing again... Why did you mark this topic as solved? My advice, Remake the Table. Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-462228 Share on other sites More sharing options...
ccrevcypsys Posted February 11, 2008 Author Share Posted February 11, 2008 I did remake. The problem i had was i was trying to make this a Key and i could just use it as an index to get it to work. So thats what i did and now it works. Thank you phpSensei for the help Link to comment https://forums.phpfreaks.com/topic/90132-solved-cant-make-a-row-with-auto_increment/#findComment-464048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.