Arg

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Pocketx
Forum Commoner
Posts: 37
Joined: Fri Aug 23, 2002 9:54 pm

Arg

Post by Pocketx »

Hello, im trying to create my sessoin and comments tables. But i get errors, what am i doing wrong? Please help

CREATE TABLE session (
id int(14) NOT NULL auto_increment,
sessionid varchar(255) NOT NULL default '',
username varchar(20) NOT NULL default '',
auth int(14) NOT NULL default '0',
userid int(14) NOT NULL default '0',
firstname varchar(50) NOT NULL default '',
lastname varchar(50) NOT NULL default '',
PRIMARY KEY (id)
);

and

CREATE TABLE `comments` (
`id` INT(14) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`newsid` INT NOT NULL
`userid` INT(14) NOT NULL,
`comment` TEXT NOT NULL,
`date` TIMESTAMP NOT NULL
);
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

well showing us the table wont help, tell us the error please.
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

One comment - shouldn't an Int be 4???? Don't know that in MySql you have to specify size, as that is a given for int, smallint, bigint, etc.

Check out some of the software good for managing databases , such as
WinSQL or Mascon - see http://www.scibit.com/Products/Software ... Mascon.htm
for the latter.
Phil J.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you also checked you syntax against that in the manual:
http://www.mysql.com/doc/en/CREATE_TABLE.html

As evilcoder said, it will also help us to help you if you tell us what the error message is.

Mac
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

CREATE TABLE session (
id int(14) NOT NULL auto_increment,
sessionid varchar(255) NOT NULL default '',
username varchar(20) NOT NULL default '',
auth int(14) NOT NULL default '0',
userid int(14) NOT NULL default '0',
firstname varchar(50) NOT NULL default '',
lastname varchar(50) NOT NULL default '',
PRIMARY KEY (id)
);
Maybe it would be easier to store the user information in one field. My table contains these felds

Code: Select all

sesskey varchar(32)  primary key
expiry int(11) unsignged
address text
value text
All the data goes into the value field. If there is more than one piece of data, it goes in as a serialized array. This way, the table above is essentially generic and can be used for many different projects. You just have to be consistent with how you map data in and out of the value field.

One more thing. The address field is for storing the IP address of the person that started the session. I IP lock sessions.

Cheers,
BDKR
Post Reply