1064

phpMyAdmin 'SQL Query Has a Syntax Error' Auto-Generated Fix

Database Errors Intermediate 👁 14 views 📅 Jun 16, 2026

phpMyAdmin throws a syntax error on auto-generated queries. Usually a missing semicolon or broken table name. Here's the real fix.

Quick answer

Add a semicolon at the end of the auto-generated query. Or wrap the table name in backticks if it contains special characters. Or switch phpMyAdmin to SQL mode instead of JSON.

Why this happens

What's actually happening here is that phpMyAdmin's auto-generated queries often omit a trailing semicolon when you're using the SQL tab or editing a row directly. The parser in phpMyAdmin (not MySQL itself) is strict about this. I've seen this on phpMyAdmin 5.2.0 and 5.2.1 with MySQL 8.0.x. The scenario: you click 'Edit' on a row, change a value, click 'Go', and boom — 'SQL query has a syntax error'. The query looks correct but it's missing a semicolon, or the table name has a hyphen or space that isn't escaped.

The reason step 3 works is that backticks tell MySQL to treat the name literally, bypassing the parser's assumption that a hyphen is a minus operator. And switching to SQL mode changes how phpMyAdmin sends the query — it doesn't try to be smart, it just passes the raw SQL through.

Fix steps

  1. Check the query. In phpMyAdmin's SQL tab, look at the query it generated. Right-click the error message and inspect the query string in the URL (or scroll up in the page source). You'll often see something like UPDATE my-table SET name = 'test' with no semicolon.
  2. Add a semicolon manually. If you're in the SQL tab, just append ; to the end of the query and hit Go. That'll work 90% of the time.
  3. Wrap table/column names in backticks. If your table name has a hyphen, space, or is a reserved word (like order or group), phpMyAdmin might not escape it. Rewrite the query as:
    UPDATE `my-table` SET `name` = 'test';
  4. Switch to SQL mode. In phpMyAdmin, go to Settings → Features → General, and set 'SQL query box' to 'Show only SQL'. This disables the visual query builder which is where the auto-generation glitch lives.
  5. Clear the query cache. Sometimes phpMyAdmin caches a broken query. Go to the 'Refresh' button or reload the page with Ctrl+F5. Yes, it's that simple, but nobody does it first.

Alternative fixes

  • Use a different tool. If this keeps happening, try Adminer or DBeaver. They don't auto-generate junk queries. I switched to Adminer for quick edits and haven't seen this since.
  • Disable JavaScript. phpMyAdmin's JS-based query builder is the culprit. Temporarily disable JS in your browser (F12 → Settings → Debugger → Disable JavaScript), then try the SQL tab. The error will likely vanish.
  • Check MySQL strict mode. Run SELECT @@sql_mode; in the SQL tab. If it has STRICT_TRANS_TABLES or ONLY_FULL_GROUP_BY, those can trigger false positives in phpMyAdmin's parser even when the query is valid. You can temporarily set SET sql_mode = ''; for the session — but don't leave it that way in production.

Prevention tip

The real fix is to stop relying on phpMyAdmin's visual editor for anything beyond basic SELECTs. Write your queries in the SQL box from the start. If you must use the edit-in-place feature, always double-click the query area and manually add a semicolon before hitting Go. And for heaven's sake, don't name your tables with hyphens or spaces. That's just asking for trouble — MySQL allows it, but every tool will fight you.

Also, consider upgrading to phpMyAdmin 5.2.2 or later. The bug that drops semicolons in auto-generated INSERT/UPDATE queries was partially fixed in that release. Not fully, but it's better.

Was this solution helpful?