Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Using PHP with MySQL Connecting PHP to MySQL Creating the Products Table

CREATE is not valid in this position

Hi, I am trying to set up my data base. However after creating the data base and trying to create a new table table. I keep getting a syntax error that CREATE is not valid in this position.

I have ran USE 'mytablename' so I know it is created. I have added a create to make sure the table I am about to create does not exist. I have even check the sql syntax for MYSQL 5 which says I am creating the new table the correct way but I can't get my line to run.

2 Answers

I am sorry but I have ran out of my psychic juice for today.. could you please let me know what QUERY you are trying to do?

usually you do not do use tablename.. you do USE DATABASE_NAME then you do something like:

Create table_name (
     id   int(20) NOT NULL,
     name varchar2(200) NOT NULL,
     address varchar2(255) NOT NULL
);

Im sorry. I made a mistake. I run USE database_name, its highlights the correct schema in mysql workbench. If I then try to copy and paste the same line of code you mention. I get the error I mention above.

I was using the wrong key words for the MY SQL Server edition, for 5.5 CREATE TABLE table_name is required.