warhead2020 Posted July 3, 2009 Share Posted July 3, 2009 I tried to run this command CREATE TABLE ‘categories’ ( ‘id’ INT NOT NULL AUTO_INCREMENT , ‘name’ VARCHAR( 255 ) NOT NULL , ‘shortdesc’ VARCHAR( 255 ) NOT NULL , ‘longdesc’ TEXT NOT NULL , ‘status’ ENUM( ‘active’, ‘inactive’ ) NOT NULL , ‘parentid’ INT NOT NULL , PRIMARY KEY ( ‘id’ ) ) TYPE = MYISAM ; but i got this error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘active’, ‘inactive’ ) NOT NULL , ‘parentid’ INT NOT NULL , PRIMAR' at line 6 can anyone help me? thanx in advance.. Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/ Share on other sites More sharing options...
xtopolis Posted July 3, 2009 Share Posted July 3, 2009 Could it be the weird quote marks you're using? Try copy pasting this: CREATE TABLE `categories` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR( 255 ) NOT NULL , `shortdesc` VARCHAR( 255 ) NOT NULL , `longdesc` TEXT NOT NULL , `status` ENUM( 'active', 'inactive' ) NOT NULL , `parentid` INT NOT NULL , PRIMARY KEY ( 'id' ) ) TYPE = MYISAM ; and see if you get the same error? Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868161 Share on other sites More sharing options...
warhead2020 Posted July 3, 2009 Author Share Posted July 3, 2009 Could it be the weird quote marks you're using? Try copy pasting this: CREATE TABLE `categories` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR( 255 ) NOT NULL , `shortdesc` VARCHAR( 255 ) NOT NULL , `longdesc` TEXT NOT NULL , `status` ENUM( 'active', 'inactive' ) NOT NULL , `parentid` INT NOT NULL , PRIMARY KEY ( 'id' ) ) TYPE = MYISAM ; and see if you get the same error? ..sory wrong quote stil error... #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''id' ) ) TYPE = MYISAM' at line 8 Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868163 Share on other sites More sharing options...
xtopolis Posted July 3, 2009 Share Posted July 3, 2009 Try changing this line PRIMARY KEY ( 'id' ) to PRIMARY KEY ( `id` ) I did a global replace on your quotes, so I forgot to correct it. That should fix it I think. Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868164 Share on other sites More sharing options...
warhead2020 Posted July 3, 2009 Author Share Posted July 3, 2009 Try changing this line PRIMARY KEY ( 'id' ) to PRIMARY KEY ( `id` ) I did a global replace on your quotes, so I forgot to correct it. That should fix it I think. sory ..i stil cant understand it....what is the diff between mine and urs? PRIMARY KEY ( `id` ) Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868166 Share on other sites More sharing options...
xtopolis Posted July 3, 2009 Share Posted July 3, 2009 The back tick ` is used to escape column/table names that use reserved words. It is the special identifier stating that `thetexthere` is the name of a table or column. Single quotes ' are used to denote strings , in this example for a "yet to be" column name. CREATE TABLE `categories` ( # `categories` refers to a table name `id` INT NOT NULL AUTO_INCREMENT , # `id` refers to a column name `name` VARCHAR( 255 ) NOT NULL , #etc `shortdesc` VARCHAR( 255 ) NOT NULL , #etc `longdesc` TEXT NOT NULL , #etc `status` ENUM( 'active', 'inactive' ) NOT NULL , # -- 'active', 'inactive' are strings for yet to be columns `parentid` INT NOT NULL , #`parentid` is a column name PRIMARY KEY ( `id` ) #refering to the column `id` ) TYPE = MYISAM ; The last one for PRIMARY KEY( `id` ) may be a little confusing, but that's just how it is. (Assuming it worked) Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868167 Share on other sites More sharing options...
warhead2020 Posted July 3, 2009 Author Share Posted July 3, 2009 The back tick ` is used to escape column/table names that use reserved words. It is the special identifier stating that `thetexthere` is the name of a table or column. Single quotes ' are used to denote strings , in this example for a "yet to be" column name. CREATE TABLE `categories` ( # `categories` refers to a table name `id` INT NOT NULL AUTO_INCREMENT , # `id` refers to a column name `name` VARCHAR( 255 ) NOT NULL , #etc `shortdesc` VARCHAR( 255 ) NOT NULL , #etc `longdesc` TEXT NOT NULL , #etc `status` ENUM( 'active', 'inactive' ) NOT NULL , # -- 'active', 'inactive' are strings for yet to be columns `parentid` INT NOT NULL , #`parentid` is a column name PRIMARY KEY ( `id` ) #refering to the column `id` ) TYPE = MYISAM ; The last one for PRIMARY KEY( `id` ) may be a little confusing, but that's just how it is. (Assuming it worked) YES! It works! im in BLANK MODE now..can u see what is the diff between ur code and mine... CREATE TABLE `categories` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR( 255 ) NOT NULL , `shortdesc` VARCHAR( 255 ) NOT NULL , `longdesc` TEXT NOT NULL , `status` ENUM( 'active', 'inactive' ) NOT NULL , `parentid` INT NOT NULL , PRIMARY KEY ( `id` ) ) TYPE = MYISAM ; this is urs...it works. CREATE TABLE ‘categories’ ( ‘id’ INT NOT NULL AUTO_INCREMENT , ‘name’ VARCHAR( 255 ) NOT NULL , ‘shortdesc’ VARCHAR( 255 ) NOT NULL , ‘longdesc’ TEXT NOT NULL , ‘status’ ENUM( ‘active’, ‘inactive’ ) NOT NULL , ‘parentid’ INT NOT NULL , PRIMARY KEY ( `id` ) ) TYPE = MYISAM ; this is mine.. can detect anything?? Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868170 Share on other sites More sharing options...
xtopolis Posted July 3, 2009 Share Posted July 3, 2009 CREATE TABLE ‘categories’ ( ‘id’ INT NOT NULL AUTO_INCREMENT , ‘name’ VARCHAR( 255 ) NOT NULL , ‘shortdesc’ VARCHAR( 255 ) NOT NULL , ‘longdesc’ TEXT NOT NULL , ‘status’ ENUM( ‘active’, ‘inactive’ ) NOT NULL , #this line has incorrect quotes ‘parentid’ INT NOT NULL , PRIMARY KEY ( `id` ) ) TYPE = MYISAM ; That line is using your version of single quotes which I'm sure it doesn't like. Use this version of single quote: ' So that line will now look like this: ‘status’ ENUM( 'active', 'inactive' ) NOT NULL , # mine instead of this ‘status’ ENUM( ‘active’, ‘inactive’ ) NOT NULL , # yours I changed the ‘active’, ‘inactive’ --to--> 'active', 'inactive' - I am using normal single quotes for those string values, you are not. Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868172 Share on other sites More sharing options...
warhead2020 Posted July 3, 2009 Author Share Posted July 3, 2009 oh ok....i found the real culprit here... actually i just copy and paste tutorial from PDF...so actually there r using ‘ but when i paste it in notepad...it is actually diff character. anyway..many2 thanx from me. Quote Link to comment https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.