Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.