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

4
  • I think you need to specify a value there (eg. VARCHAR(255)). Commented Aug 11, 2013 at 23:57
  • possible duplicate of Syntax error in SQL create table Commented Aug 12, 2013 at 0:05
  • @AlexJimenez: Mr. Jimenez, if any of these answers helped you, please see to it that you accept the one that solved your issue. Thank you. Commented Aug 12, 2013 at 0:45
  • Varchar(MAX) is a SQL Server specific extension. You'll have to put a number in there... Commented Aug 12, 2013 at 4:25

3 Answers 3

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)
Sign up to request clarification or add additional context in comments.

Comments

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?

Comments

0

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

See:

I think you want:

...
Post VARCHAR(65535),
...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.