Gregory Sims
Gregory Sims

Reputation: 551

Strange MySQL error to insert query

I am trying to insert a row into a table in mysql.This should be simple, but for some reason I'm getting an unexpected response. This is the query I am trying to execute:

INSERT INTO users (username, email, password) VALUES (testuser, testuseratdomaincom, testpass)

My table looks like so: http://pastebin.com/RmLZHWW8

However, when I run the query I get this response:

Failed to execute SQL : SQL INSERT INTO users (username, email, password) VALUES (testuser, testuseratdomaincom, testpass) failed : Unknown column 'testuser' in 'field list'

It's trying to find a column called 'testuser' which should be the value for the username column. What is going on?

Upvotes: 0

Views: 30

Answers (3)

Doug Kress
Doug Kress

Reputation: 3537

You should put your values in quotes.

INSERT INTO users (username, email, password) VALUES ('testuser', 'testuseratdomaincom', 'testpass');

Upvotes: 0

Fabian S.
Fabian S.

Reputation: 2529

You need to quote your values like 'testuser'. Your current query searches for a field 'testuser' in the table 'users' for inserting it into 'username'.

Correct query:

INSERT INTO users (username, email, password) VALUES ('testuser', 'testuseratdomaincom', 'testpass')

Upvotes: 1

Eduard Uta
Eduard Uta

Reputation: 2617

the values should have quotes before and after.

Upvotes: 1

Related Questions