PHP PHP MySQLi Debugging SQL in MySQLi


So your query has failed (see MySQLi connect for how we made $conn)

$result = $conn->query('SELECT * FROM non_existent_table'); // This query will fail

How do we find out what happened? $result is false so that's no help. Thankfully the connect $conn can tell us what MySQL told us about the failure


or procedural


You should get an error similar to

Table 'my_db.non_existent_table' doesn't exist