Take note:
Calling this function will change the output of mysqli_affected_rows if any warnings are returned. So if you're using mysqli_affected_rows in your application, make sure to call it before calling mysqli_get_warnings.(PHP 5 >= 5.1.0, PHP 7, PHP 8)
mysqli::get_warnings -- mysqli_get_warnings — Obtém o resultado de SHOW WARNINGS
Estilo orientado a objetos
Estilo procedural
   Retorna uma lista vinculada individualmente composta por
   mysqli_warning ou false se não houver alertas.
   Cada objeto na lista corresponde a uma única linha do resultado de
   SHOW WARNINGS.
   Chamar mysqli_warning::next() irá recarregar o objeto
   com os valores da próxima linha.
  
Nota: Para recuperar mensagens de alerta, é recomendado usar o comando SQL
SHOW WARNINGS [limit row_count]em vez desta função.
A lista vinculada não pode ser retrocedida ou recuperada novamente.
mysqlSomente no estilo procedural: Um objeto mysqli retornado por mysqli_connect() ou mysqli_init()
   Retorna uma lista vinculada individualmente composta por
   mysqli_warning ou false se não houver alertas.
  
Exemplo #1 Percorrendo a lista vinculada para buscar todos os alertas
Estilo orientado a objetos
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query("SELECT 1/0, CAST('NULL' AS UNSIGNED)");
if ($mysqli->warning_count > 0) {
    $warning = $mysqli->get_warnings();
    if ($warning !== false) {
        do {
            printf("Número do erro: %s\n", $warning->errno);
            printf("Mensagem: %s\n", $warning->message);
        } while ($warning->next());
    }
}Estilo procedural
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = mysqli_connect("localhost", "user", "password", "test");
mysqli_query($link, "SELECT 1/0, CAST('NULL' AS UNSIGNED)");
if (mysqli_warning_count($link) > 0) {
    $warning = mysqli_get_warnings($link);
    if ($warning !== false) {
        do {
            printf("Número do erro: %s\n", $warning->errno);
            printf("Mensagem: %s\n", $warning->message);
        } while ($warning->next());
    }
}Os exemplos acima produzirão:
Número do erro: 1365 Mensagem: Division by 0 Número do erro: 1292 Mensagem: Truncated incorrect INTEGER value: 'NULL'
