How can error_reporting be effectively used in PHP to troubleshoot issues with database queries?

When troubleshooting database query issues in PHP, setting the error_reporting level to E_ALL can help in identifying and resolving errors. By enabling error_reporting, PHP will display all types of errors, warnings, and notices, including those related to database queries. This can help in pinpointing the exact issue and resolving it effectively.

// Enable error reporting for all types of errors
error_reporting(E_ALL);

// Your database connection code here

// Your database query code here