#1064 error in server

Avatar
  • Answered
#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 ''friends'(
'Id' int(10) NOT NULL AUTO_INCREMENT,
'providerid' int(10) NOT NULL' at line 1

my code :
CREATE TABLE IF NOT EXISTS 'friends'(
'Id' int(10) NOT NULL AUTO_INCREMENT,
'providerid' int(10) NOT NULL AUTO_INCREMENT,
'requestid' int(10) NOT NULL AUTO_INCREMENT,
'status' binary(1) NOT NULL DEFAULT
PRIMARY KEY('Id'),
)

CREATE TABLE IF NOT EXISTS 'messages'(
'id' int(255) NOT NULL AUTO_INCREMENT,
'fromuid' int(255) NOT NULL,
'touid' int(255) NOT NULL,
'sentdt' datetime NOT NULL,
'read' tinyint(1) NOT NULL DEFAULT '0',
'readdt' datetime DEFAULT NULL,
'messagetext' longtext CHARACTER SET utf8 NOT NULL,
PRIMARY KEY('id'),
)


CREATE TABLE IF NOT EXISTS 'users'(
'Id' int(10) unsigned NOT NULL AUTO_INCREMENT,
'username' varchar(45) NOT NULL DEFAULT '',
'password' varchar(32) NOT NULL DEFAULT '',
'email' varchar(45) NOT NULL DEFUALT '',
'date' datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
'status' tinyint(3) unsigned NOT NULL DEFAULT '0',
'authenticationTime' datetime NOT DEFAULT DEFAULT '0000-00-00 00:00:00',
'userKey' varchar(32) NOT NULL DEFAULT '',
'IP' varchar(45) NOT NULL DEFAULT '',
'port' int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY ('Id'),
)

Avatar
johnpaulb-imhs1
Hello, Thank you for your question regarding a 1064 error. Since it indicates an error on this lin, try adding a space after: 'friends' Also, ensure you are using backticks instead of single quotation marks. Here is a helpful link to the official mySQL guide on creating table, it includes examples on the "CREATE TABLE IF NOT EXISTS" format. Thank you, John-Paul