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

PHP

Adam Smallman
Adam Smallman
4,182 Points

Cant create new database in SQL

In php My Admin 4.1.12

CREATE DATABASE Test

CREATE TABLE joke ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, joketext TEXT, jokedate DATE NOT NULL ) tf8 ENGINE=InnoDB

When I press "go" I get an Error message saying

Error SQL query:

CREATE DATABASE Test

CREATE TABLE joke ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, joketext TEXT, jokedate DATE NOT NULL ) tf8 ENGINE=InnoDB MySQL said: Documentation

1064 - 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 'CREATE TABLE joke (

id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, joketext T' at line 3

Any ideas ? I am coping the code exact.

I don't see a semicolon anywhere in your SQL statement, I ran

CREATE TABLE joke ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, joketext TEXT, jokedate DATE NOT NULL );

on my local machine and it created the table without any issues. I don't use InnoDB, so I excluded it on purpose.

1 Answer

It appears you are trying to set a character set, however you are missing it's property call. The tf8 should be CHAR SET=utf8

Below should work: ... CREATE TABLE joke ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, joketext TEXT, jokedate DATE NOT NULL ) CHAR SET=utf8 ENGINE=InnoDB; ...