0

I am trying to create a table in MySql using php. My code looks like this:

$sql = "CREATE TABLE qotwQuestion1111 ( QuestionId int PRIMARY KEY AUTOINCREMENT, Question varchar(5000), MemberId varchar(255) FOREIGN KEY REFERENCES qotwMember(MemberId), PostDate date, Vote int )"; mysql_query($sql,$con);

i am unable to create this table, the error is in the "AUTOINCREMENT" and also the "FOREIGN KEY" ..

Can someone tell me what am i doing wrong here. and what should i do to solve this problem please

Best Zeeshan

1 Answer 1

5

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

The keyword is AUTO INCREMENT

http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html

foreign keys are specified as constraints or by FOREIGN KEY fk_name REFERENCES table(key) .

When you have a problem with your sql syntax, it tells you to check your sql manual near where the error occurred. I suggest you take its advice.

Sign up to request clarification or add additional context in comments.

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.