By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,913 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,913 IT Pros & Developers. It's quick & easy.

tutorial problem discussionforumswithphp

P: 1
I just went through your discussion forum tutorial and got an error with first database querry

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE posts (
  2.     ID int(5) DEFAULT '0' NOT NULL auto_increment,
  3.     TopicID int(5) DEFAULT '0' NOT NULL,
  4.     Name varchar(50) NOT NULL,
  5.     Email varchar(50) NOT NULL,
  6.     Password varchar(50) NOT NULL,
  7.     TimeStamp varchar(10) NOT NULL,
  8.     Post text NOT NULL,
  9.     PRIMARY KEY (ID)
  10.  );
error is :

#1067 - Invalid default value for 'ID'

pls provide solution for this

my configuration is:

php version 5.5+
and using phpmyadmin for database work.

using xampp.
Mar 24 '14 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,112
Hi parthrpatel80 and welcome to!

I don't know the tutorial but I have a guess as to why the above code doesn't work: for both ID and TopicID it expects an integer and you seem to be passing a string. Try the following:
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE posts (
  2. ID int(5) DEFAULT 0 NOT NULL auto_increment,
  3. TopicID int(5) DEFAULT 0 NOT NULL,
  4. Name varchar(50) NOT NULL,
  5. Email varchar(50) NOT NULL,
  6. Password varchar(50) NOT NULL,
  7. TimeStamp varchar(10) NOT NULL,
  8. Post text NOT NULL,
  10. );
Mind you, I haven't done any database stuff for a while and haven't tested it, so no promises. ;-)
Mar 24 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.