tags:

views:

52

answers:

1

Hello

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

+5  A: 

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.

Ben Hughes
Thanks for the suggestion..
Zeeshan Rang