proggR Posted July 23, 2008 Share Posted July 23, 2008 I have a db setup and a table with the columns postID, file, title, course, date and directory. postID is the primary key and is set to auto increment. When I go to insert the values do I skip the postID and start on the file or do I have to insert the postID everytime? or just the first time? I'm assuming INSERT INTO table VALUES ('$file', '$title', '$course', '$date', '$directory') would throw an error since it would see the first value in $file and try to insert it in the postID columb which is an INT (wheras file is VARCHAR). Could anyone clarify this? Link to comment https://forums.phpfreaks.com/topic/116196-solved-inserting-values-with-auto-increment/ Share on other sites More sharing options...
accident Posted July 23, 2008 Share Posted July 23, 2008 Just throw in a null and that will auto increment so for example INSERT INTO table VALUES (null, '$file', '$title', '$course', '$date', '$directory') Link to comment https://forums.phpfreaks.com/topic/116196-solved-inserting-values-with-auto-increment/#findComment-597486 Share on other sites More sharing options...
proggR Posted July 23, 2008 Author Share Posted July 23, 2008 Ok thanks. I also realized i could go INSERT INTO table (file, title etc....) but that's just a hassle so thank you . And also, with the auto increment, does it default my first value to one so i NEVER have to enter anything for it. Or do i have to initialize it at one the first time its used? Link to comment https://forums.phpfreaks.com/topic/116196-solved-inserting-values-with-auto-increment/#findComment-597488 Share on other sites More sharing options...
accident Posted July 23, 2008 Share Posted July 23, 2008 It will default to one on your first insert unless you run this command on your table ALTER TABLE tbl AUTO_INCREMENT = 1000 which will start the value at 1000 instead of 1 Link to comment https://forums.phpfreaks.com/topic/116196-solved-inserting-values-with-auto-increment/#findComment-597489 Share on other sites More sharing options...
proggR Posted July 23, 2008 Author Share Posted July 23, 2008 Ok thanks All I needed to know (for now ) Link to comment https://forums.phpfreaks.com/topic/116196-solved-inserting-values-with-auto-increment/#findComment-597495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.