Jump to content

Trying to automate database table creating


dt_gry

Recommended Posts

Hi guys,

 

I am trying to automate database table creation using database.sql (executing in puTTY) and I am getting

the following error

 

./database.sql: line 1: syntax error near unexpected token `('

./database.sql: line 1: `CREATE TABLE 'users' ('

 

Here is my code:

 

CREATE TABLE 'users' (
  'id' int(11) NOT NULL auto_increment,
  'username' varchar(30) NOT NULL default '',
  'password' varchar(40) NOT NULL default '',
  'email' varchar(140) NOT NULL default '',
  'regdate' int(10) NOT NULL default '0',
  'ip' varchar(15) NOT NULL default '',
  'lastdate' int(10) NOT NULL default '0',
  PRIMARY KEY  ('id')
);

CREATE TABLE 'forgot' (
  'username' varchar(30) NOT NULL default '',
  'password' varchar(40) NOT NULL default '',
  'email' varchar(140) NOT NULL default '',
  'regdate' int(10) NOT NULL default '0',
  'ip' varchar(15) NOT NULL default ''
);

 

Any ideas?

 

Thanks

dt_gry

Link to comment
Share on other sites

That didn't work.

 

New CODE

CREATE TABLE "users" (
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(30) NOT NULL default ``,
  `password` varchar(40) NOT NULL default ``,
  `email` varchar(140) NOT NULL default ``,
  `regdate` int(10) NOT NULL default `0`,
  `ip` varchar(15) NOT NULL default ``,
  `lastdate` int(10) NOT NULL default `0`,
  PRIMARY KEY  (`id`)
);

CREATE TABLE "forgot" (
  `username` varchar(30) NOT NULL default ``,
  `password` varchar(40) NOT NULL default ``,
  `email` varchar(140) NOT NULL default ``,
  `regdate` int(10) NOT NULL default `0`,
  `ip` varchar(15) NOT NULL default ``
);

 

 

Thanks

dt_gry

Link to comment
Share on other sites

You're problem lies with default.  You need to specify a value like this:

regdate int(10) NOT NULL default '0'

 

So here's working code, without defaults

CREATE TABLE users (
  id int(11) NOT NULL AUTO_INCREMENT,
  username varchar(30) NOT NULL,
  password varchar(40) NOT NULL,
  email varchar(140) NOT NULL,
  regdate int(10) NOT NULL,
  ip varchar(15) NOT NULL,
  lastdate int(10) NOT NULL,
  PRIMARY KEY  (id)
);

CREATE TABLE forgot (
  username varchar(30) NOT NULL,
  password varchar(40) NOT NULL,
  email varchar(140) NOT NULL,
  regdate int(10) NOT NULL,
  ip varchar(15) NOT NULL  
);

Link to comment
Share on other sites

What happens when you try this:

 

CREATE TABLE "users" (
  "id" int(11) NOT NULL AUTO_INCREMENT,
  "username" varchar(30) NOT NULL,
  "password" varchar(40) NOT NULL,
  "email" varchar(140) NOT NULL,
  "regdate" int(10) NOT NULL,
  "ip" varchar(15) NOT NULL,
  "lastdate" int(10) NOT NULL,
  PRIMARY KEY  ("id")
);

CREATE TABLE "forgot" (
  "username" varchar(30) NOT NULL,
  "password" varchar(40) NOT NULL,
  "email" varchar(140) NOT NULL,
  "regdate" int(10) NOT NULL,
  "ip" varchar(15) NOT NULL  
);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.