zamp0e Posted June 7, 2009 Share Posted June 7, 2009 I'm having an error when I try to set my 'id' column to null: Error in query: INSERT into recept VALUES (NULL, 'Array', 'Array', 'CURDATE()',1,0,'Array'). Column 'id' cannot be null What is the problem ? I'm sure that 'id' is auto_increment. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/ Share on other sites More sharing options...
gevans Posted June 7, 2009 Share Posted June 7, 2009 I'm sure that 'id' is auto_increment. Have you checked that? Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851007 Share on other sites More sharing options...
.josh Posted June 7, 2009 Share Posted June 7, 2009 if the column is auto_increment then it cannot be null. You don't see how those 2 things do not work together? Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851009 Share on other sites More sharing options...
Daniel0 Posted June 7, 2009 Share Posted June 7, 2009 Another thing, try to run these queries from phpMyAdmin or the MySQL console: SELECT 'CURDATE()'; and SELECT CURDATE(); and tell me the difference in return values. Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851011 Share on other sites More sharing options...
zamp0e Posted June 7, 2009 Author Share Posted June 7, 2009 SELECT 'CURDATE()'; : CURDATE() CURDATE() SELECT CURDATE(); : CURDATE() 2009-06-07 I see your point, thanks. And I've been using auto_increment before with NULL and it have been working, should I change ID to not be auto_increment ? Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851013 Share on other sites More sharing options...
gevans Posted June 7, 2009 Share Posted June 7, 2009 No, you leave it ask auto-increment, and specify what fields to fill; INSERT into recept (field1,field2 etc...(without id)) VALUES ('Array', 'Array', CURDATE(),1,0,'Array') Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851014 Share on other sites More sharing options...
Daniel0 Posted June 7, 2009 Share Posted June 7, 2009 Could you post the output of SHOW CREATE TABLE recept; ? Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851018 Share on other sites More sharing options...
zamp0e Posted June 7, 2009 Author Share Posted June 7, 2009 I'm very new to this so I make alot of misstakes at the moment. Thanks alot for your help! Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851019 Share on other sites More sharing options...
zamp0e Posted June 7, 2009 Author Share Posted June 7, 2009 Sorry, the table is actully name "users", misstyping. users CREATE TABLE `users` ( `id` int(255) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `made` date NOT NULL, `status` int(255) NOT NULL, `antalrecept` int(255) NOT NULL, `email` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851020 Share on other sites More sharing options...
Daniel0 Posted June 7, 2009 Share Posted June 7, 2009 INSERT into users VALUES (NULL, 'Array', 'Array', CURDATE(),1,0,'Array') Executes fine for me on that table. Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851026 Share on other sites More sharing options...
zamp0e Posted June 7, 2009 Author Share Posted June 7, 2009 I copied your line and it works fine for me to now, seems like I've wasted your time in vein. Thanks for the help though. Quote Link to comment https://forums.phpfreaks.com/topic/161276-solved-cannot-be-null/#findComment-851028 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.