PDO Table Not Found
Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myapp.users' doesn't existQuick Answer
The database table referenced in your query does not exist. Check the table name for typos, verify you are connected to the correct database, and ensure migrations have been run.
Why This Happens
This error occurs when your SQL query references a table that does not exist in the connected database. Common causes include not running database migrations, connecting to the wrong database, typos in table names, or the table being dropped or renamed.
The Problem
$stmt = $pdo->query('SELECT * FROM user'); // Table is actually named 'users'The Fix
$stmt = $pdo->query('SELECT * FROM users'); // Correct table nameStep-by-Step Fix
- 1
Verify the table name
Check the exact table name in the error and compare it to your database schema. Look for typos or singular/plural mismatches.
- 2
Check the database
Verify you are connected to the correct database by checking the DSN. Run SHOW TABLES to see available tables.
- 3
Run migrations
If the table should exist, run your database migration tool to create it. Check that the migration was not skipped or failed.
Bugsly catches this automatically
Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.
Try Bugsly free