Is it possible for a query result to return an error message in PHP when using an insert query that does not produce a result set?

When executing an insert query in PHP that does not produce a result set, it is not possible to directly check for errors using functions like `mysqli_error()` as these functions are used for result sets. However, you can check for errors by using `mysqli_affected_rows()` to determine the number of affected rows after the insert query. If `mysqli_affected_rows()` returns -1, it indicates an error occurred during the insert operation.

// Execute the insert query
$result = mysqli_query($conn, "INSERT INTO table_name (column1, column2) VALUES ('value1', 'value2')");

// Check for errors
if(mysqli_affected_rows($conn) == -1) {
    echo "Error: " . mysqli_error($conn);
} else {
    echo "Insert successful!";
}