ilikeyoyo
ilikeyoyo

Reputation: 178

I keep getting an error when trying to make a table in phpmyadmin

when I was trying to run this code:

USE user;

CREATE TABLE IF NOT EXISTS 'posts' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'body' text NOT NULL,
'date_added' date NOT NULL,
'added_by' varchar(255) NOT NULL,
'user_posted_to' varchar(255) NOT NULL,
PRIMARY KEY ('id')
)ENGINE=MYISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10;

It gave me 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 ''posts' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'body' text NOT NULL,
'dat' at line 1 

how do I solve it? By the way, I already selected a database? Any help would be appreciated.

Upvotes: 0

Views: 43

Answers (1)

ethrbunny
ethrbunny

Reputation: 10479

Get rid of all the "'" marks.

CREATE TABLE IF NOT EXISTS posts (
  id int(11) NOT NULL AUTO_INCREMENT,
  body text NOT NULL,
  date_added date NOT NULL,
  added_by varchar(255) NOT NULL,
  user_posted_to varchar(255) NOT NULL,
  PRIMARY KEY (id)
  )ENGINE=MYISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10;

Here is a fiddle with a working creation.

Upvotes: 2

Related Questions