1064

MySQL Error 1064 on INSERT: Missing Quotes Around Strings

You're getting a syntax error on INSERT because MySQL thinks your string values are column names or SQL keywords. The fix is wrapping text values in single quotes.

Yeah, Error 1064 on an INSERT statement is annoying. But 90% of the time it's one thing: you forgot single quotes around a string value. Let me show you the fix, then explain the mechanic.

The Fix (Works 9 Out of 10 Times)

Say you wrote this:

INSERT INTO users (name, email, age) VALUES (John, john@example.com, 25);

MySQL throws 1064 right near 'John'. Fix it by putting single quotes around the string values:

INSERT INTO users (name, email, age) VALUES ('John', 'john@example.com', 25);

That's it. Numbers like 25 don't need quotes. Strings do. If you're coming from Python or PHP where variables are unquoted, this catches you.

Why It Works

Here's what's actually happening. MySQL sees John without quotes and thinks it's a column name or a table name. Since there's no column called John in your table, it barfs with a syntax error. The parser hits John right after VALUES ( and expects either a number, a quoted string, or a function call. It doesn't get any of those, so it reports the error near the first unexpected token.

The error message itself is misleading. It says "near INSERT" but the real mistake is two lines later in the VALUES clause. MySQL just points at the INSERT keyword because it can't recover the parse position correctly after it fails.

Less Common Variations

Reserved Words as Column Names Without Backticks

If your table or column name matches a MySQL reserved word (like order, select, group), you need backticks:

INSERT INTO orders (order, status) VALUES ('ABC', 'shipped');  -- wrong
INSERT INTO orders (`order`, `status`) VALUES ('ABC', 'shipped');  -- right

Missing Comma or Extra Comma

Another one: you skip a comma between values or add one at the end. This triggers 1064 too:

INSERT INTO items (name, price) VALUES ('Widget', 10 'Tax');  -- missing comma
INSERT INTO items (name, price) VALUES ('Widget', 10,);       -- trailing comma

MySQL's parser hits the unexpected token and throws 1064. The error location shifts to the INSERT keyword again.

Using Double Quotes Instead of Single Quotes

By default, MySQL on strict mode treats double quotes as identifier quotes (like backticks) unless you set ANSI_QUOTES. So INSERT INTO t (col) VALUES ("hello") is parsed as a column named hello, not a string. Use single quotes for string literals unless you've changed the SQL mode.

Newline or Hidden Characters in the Query

If you copy-paste an INSERT from a web page or a PDF, you sometimes get invisible characters (like zero-width spaces) that break parsing. Retype the VALUES line manually if nothing else works.

Prevention Tips

Here's what I do to never see this error again:

  • Use prepared statements with parameterized queries. In PHP that's PDO or MySQLi. In Python it's cursor.execute("INSERT ... VALUES (%s, %s)", (val1, val2)). This handles quoting automatically.
  • Write your INSERT in a SQL editor with syntax highlighting. Strings show up in a different color. If you see plain text in the VALUES section that's the same color as column names, you missed quotes.
  • Test the INSERT as a SELECT first. Write SELECT 'John', 'john@example.com', 25 and see if it runs. If it does, paste those same values into the INSERT.
  • Set sql_mode = 'STRICT_TRANS_TABLES'. This won't fix 1064, but it will catch other data type mismatches earlier.

That's the whole story. Next time you see 1064 on an INSERT, check quotes first. You'll fix it in under a minute.

Related Errors in Database Errors
0XC0190045 STATUS_TRANSACTIONS_NOT_FROZEN (0XC0190045) fix for VSS backups 1292 Fixing MySQL 'Error 1292: Truncated incorrect DOUBLE value' 0X800F023A Fix SPAPI_E_PNP_REGISTRY_ERROR (0x800f023a) the Right Way 0X00001A9F Fix ERROR_HANDLE_NO_LONGER_VALID (0x1A9F) Transaction Handle

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.