SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot rrreview's Avatar
    Join Date
    Jul 2002
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Real quick - MySQL syntax error on table creation.

    I get this error when I run the script. 1064: You have an error in your SQL syntax near ' Password varchar(32) NOT NULL default, PRIMARY KEY (ID), UNIQUE KEY Name (Name)' at line 1.

    Here's the line of code it's on.
    PHP Code:
    $query "CREATE TABLE user (ID smallint(3) NOT NULL auto_increment, Name varchar(30) NOT NULL default, Password varchar(32) NOT NULL default, PRIMARY KEY (ID), UNIQUE KEY Name (Name))"
    I'm trying to do the creation of this tutorial ( http://robouk.mchost.com/tuts/tutori...tutorial=login ), except in PHP. Maybe you can see a syntax error.

  2. #2
    SitePoint Addict seanmayhew's Avatar
    Join Date
    Aug 2002
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have set a default you need to give it a value ie
    PHP Code:
    Name varchar(30NOT NULL default'rrreview' 
    Also I believe the proper syntax for the unique key is
    PHP Code:
    UNIQUE('Name'

  3. #3
    SitePoint Zealot rrreview's Avatar
    Join Date
    Jul 2002
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just tried a rework of the query and I *think* it works.
    PHP Code:
    $query "CREATE TABLE user (ID smallint(3) NOT NULL auto_increment, Name varchar(30) NOT NULL default 'name', Password varchar(32) NOT NULL default 'pass', PRIMARY KEY (ID), UNIQUE KEY (Name))"
    Thanks for your help by the way.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •