Jump to content


MYSQL QUERY PROBLEMS


2 replies to this topic

#1 Lyall

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 23 March 2007 - 04:57 PM

For some reason this query is wrong?

CREATE TABLE tutorial (
id int(10) NOT NULL auto_increment,
author text,
category text,
tutorial text,
title text,
ip text,
val text,
desc text,
PRIMARY KEY (id)
) TYPE = MYISAM ;

CREATE TABLE tut_comments (
id int(10) NOT NULL auto_increment,
posterNAME text,
postEMAIL text,
postTIME text,
postMSG text,
tutID text,
PRIMARY KEY (id)
) TYPE = MYISAM ;

Anybody know what i'm doing wrong, something about "desc text" ...

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 23 March 2007 - 05:17 PM

Try this.

CREATE TABLE `tutorial` (
`id` int(10) NOT NULL auto_increment,
`author` text,
`category` text,
`tutorial` text,
`title` text,
`ip` text,
`val` text,
`desc` text,
PRIMARY KEY (`id`)
) TYPE = MYISAM ;

CREATE TABLE `tut_comments` (
`id` int(10) NOT NULL auto_increment,
`posterNAME` text,
`postEMAIL` text,
`postTIME` text,
`postMSG` text,
`tutID` text,
PRIMARY KEY (`id`)
) TYPE = MYISAM ;

You most probably ran into a MySQL keyword. You should always use the appropriate characters to indicate database/table/column names to avoid this.

#3 SecondV

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Gender:Male
  • Location:Kentucky
  • Interests:All things PHP & MySQL :)

Posted 23 March 2007 - 10:45 PM

I'd recommend a structure similar to:
CREATE TABLE `tutorial` (
	`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
	`author` VARCHAR(255),
	`category`  VARCHAR(255),
	`tutorial` TEXT,
	`title`  VARCHAR(255),
	`ip` VARCHAR(20),
	`val`  VARCHAR(255),
	`desc`  VARCHAR(255),
	PRIMARY KEY (`id`)
);

CREATE TABLE `tut_comments` (
	`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
	`posterNAME` VARCHAR(255),
	`postEMAIL` VARCHAR(255),
	`postTIME` INT(11), #I'd suggest using some sort of timestamp - time() for example.
	`postMSG` TEXT,
	`tutID` INT UNSIGNED NOT NULL, #I'm just assuming this is the id from the tutorial table?
	PRIMARY KEY (`id`),
	KEY `tutID` (`tutID`)
);

View PostDemonslay, on Mar 23 2007, 06:17 PM, said:

You most probably ran into a MySQL keyword. You should always use the appropriate characters to indicate database/table/column names to avoid this.
Correct. 'desc' or 'DESC' - is a MySQL keyword.

Edited by SecondV, 23 March 2007 - 10:44 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users