Jump to content

Recommended Posts

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..

Link to comment
https://forums.phpfreaks.com/topic/164615-solved-1064-error/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868161
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868163
Share on other sites

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` )

Link to comment
https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868166
Share on other sites

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)

Link to comment
https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868167
Share on other sites

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??

Link to comment
https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868170
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/164615-solved-1064-error/#findComment-868172
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.