0

I'm creating an SQL table using PHP but I'm getting an error and I don't know why. This is the code

CREATE TABLE posts
(
    P_Id int NOT NULL AUTO_INCREMENT,
    Title VARCHAR(200),
    Post VARCHAR(MAX),
    PRIMARY KEY (P_Id)
)

The error that I'm getting is

Error creating table: 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 'MAX), PRIMARY KEY (P_Id)' at line 5

Dharman
  • 26,923
  • 21
  • 73
  • 125
elpita
  • 1,005
  • 3
  • 12
  • 12

3 Answers3

2

VARCHAR(MAX) is not supported in MySql, I think you need to specify a figure in there. I think 64k is the max.

VARCHAR(65535)
David MacCrimmon
  • 966
  • 1
  • 6
  • 19
0
CREATE TABLE posts
(_Id int NOT NULL AUTO_INCREMENT,
Title VARCHAR(200),
Post VARCHAR(MAX),
PRIMARY KEY (P_Id))

What is MAX? Got too many commas! Why are you using PHP to initialize a database?

Ed Heal
  • 57,599
  • 16
  • 82
  • 120
0

From what I can tell you can't use (MAX) for VARCHAR in mySQL.

See:

I think you want:

...
Post VARCHAR(65535),
...
Community
  • 1
  • 1
chucknelson
  • 2,290
  • 3
  • 24
  • 30