0

The table is not created in the database Users and there is no error message at all. PhpMyAdmin is set to allow no password, just to be clear on that point.

CREATE TABLE Users(
    ID string(255) NOT NULL,
    FirstName string(255) NOT NULL,
    Surname string(255) NOT NULL,
    DOB date(10) NOT NULL
)
6
  • does the query work if you run it directly in MySQL (e.g. via WorkBench)? Commented Sep 25, 2017 at 8:55
  • 3
    Mysql does not know "string". You will have to use "varchar". The date field does not need a defined length. You can leave that out. The create table query will work like this: CREATE TABLE Users( ID varchar(255) NOT NULL, FirstName varchar(255) NOT NULL, Surname varchar(255) NOT NULL, DOB date NOT NULL ) Commented Sep 25, 2017 at 8:57
  • Agreed with @natheriel Commented Sep 25, 2017 at 8:58
  • Thanks @ADyson for suggesting I run it separately, as it did give an error, I just didn't know what the error was. Commented Sep 25, 2017 at 9:06
  • Thanks @natheriel. That fixed it. Commented Sep 25, 2017 at 9:07

1 Answer 1

3

your query should be like this.

$mySql = CREATE TABLE Users(
         ID VARCHAR(255) NOT NULL,
         FirstName VARCHAR(255) NOT NULL,
         Surname VARCHAR(255) NOT NULL,
         DOB date NOT NULL
    )";
  1. MySQL can't understand string. pass varchar instead of a string.
  2. you don't need to assign the length of date.
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.