tutorial problem discussionforumswithphp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parthrpatel80
    New Member
    • Mar 2014
    • 1

    tutorial problem discussionforumswithphp

    Hi,
    I just went through your discussion forum tutorial and got an error with first database querry

    Code:
    CREATE TABLE posts (
        ID int(5) DEFAULT '0' NOT NULL auto_increment,
        TopicID int(5) DEFAULT '0' NOT NULL,
        Name varchar(50) NOT NULL,
        Email varchar(50) NOT NULL,
        Password varchar(50) NOT NULL,
        TimeStamp varchar(10) NOT NULL,
        Post text NOT NULL,
        PRIMARY KEY (ID)
     );
    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.
    Last edited by Rabbit; Mar 24 '14, 03:34 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Hi parthrpatel80 and welcome to bytes.com!

    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:
    Code:
    CREATE TABLE posts (
    ID int(5) DEFAULT 0 NOT NULL auto_increment,
    TopicID int(5) DEFAULT 0 NOT NULL,
    Name varchar(50) NOT NULL,
    Email varchar(50) NOT NULL,
    Password varchar(50) NOT NULL,
    TimeStamp varchar(10) NOT NULL,
    Post text NOT NULL,
    PRIMARY KEY (ID)
    );
    Mind you, I haven't done any database stuff for a while and haven't tested it, so no promises. ;-)

    Comment

    Working...