Jump to content

[SOLVED] 1064 ERROR


warhead2020

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

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

Archived

This topic is now archived and is closed to further replies.

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