Michael Lara
Michael Lara

Reputation: 45

Cannot save a table in phpMyAdmin

Currently training on phpMyAdmin, and tried to set up my first set of fields in the database. After I set the fields' names, types, and values, I tried to save and phpMyAdmin returned error:

Error SQL query:

CREATE TABLE  `test`.`Contact ` (
`Contact` INT NOT NULL ,
`Name` VARCHAR( 50 ) NOT NULL ,
`Company` VARCHAR( 30 ) NOT NULL ,
`Email` VARCHAR( 50 ) NOT NULL
) ENGINE = MYISAM CHARACTER SET ASCII COLLATE ascii_general_ci;
MySQL said: Documentation
#1103 - Incorrect table name 'Contact ' 

Can anyone help to find out what the problem is?

Upvotes: 3

Views: 4349

Answers (3)

krowe
krowe

Reputation: 2280

To get this to work you need to remove the space from your table name.

As a matter of convention, I would also suggest that you change the name of the Contact field to something more meaningful. I'm assuming that you want to make that your primary key. You should probably name it simply 'id'. You'll also want to set the auto increment and primary key checkboxes so that the field works as you want it to.

The primary key setting makes queries run MUCH faster on this table. It also allows you to do several things with the table which you'd otherwise be posting question on here to figure out why they don't work.

The auto increment setting will allow you to skip that field all together when creating new records. This means you won't need to lookup the highest value and add one every time you want a new record.

Upvotes: 1

Naughty Leopard
Naughty Leopard

Reputation: 63

Table name can not contain spaces! You have a whitespace after Contact: <<test.Contact (>>

Upvotes: 1

pilsetnieks
pilsetnieks

Reputation: 10430

The space character after the table name is what's causing the error. From MySQL documentation:

Database, table, and column names cannot end with space characters

Upvotes: 7

Related Questions