What are the recommended error reporting settings in PHP to effectively troubleshoot and fix issues in mysqli queries?

To effectively troubleshoot and fix issues in mysqli queries, it is recommended to set the error reporting level to E_ALL in PHP. This will display all errors, warnings, and notices, including those related to mysqli queries, which can help identify and resolve issues more quickly.

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

// Enable error reporting in PHP
ini_set('display_errors', 1);

// Connect to MySQL database using mysqli
$mysqli = new mysqli("localhost", "username", "password", "database");

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

// Perform mysqli queries here