How can error reporting be increased in PHP to better identify and troubleshoot issues with database queries?

To increase error reporting in PHP for database queries, you can set the error reporting level to display all errors, warnings, and notices related to database queries. This can help identify and troubleshoot issues more effectively.

// Set error reporting level to display all errors, warnings, and notices
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check for connection errors
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}