GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Downloads
  • Documentation
  • Get Involved
  • Help
  • Getting Started
  • Introduction
  • A simple tutorial
  • Language Reference
  • Basic syntax
  • Types
  • Variables
  • Constants
  • Expressions
  • Operators

This view

  • Original page
  • New address

GeezerVison is showing www.php.net — PHP: mysqli::$error_list - Manual

PHP 8.6.0 Released!
    mysqli::escape_string »
    « mysqli::$error
    • Preface
    • Function Reference
    • Database Extensions
    • Vendor Specific Database Extensions
    • MySQL
    • MySQLi
    • mysqli

    mysqli::$error_list

    mysqli_error_list

    (PHP 5 >= 5.4.0, PHP 7, PHP 8)

    mysqli::$error_list -- mysqli_error_list — Returns a list of errors from the last command executed

    Description

    Object-oriented style

    array $mysqli->error_list;

    Procedural style

    function mysqli_error_list(mysqli $mysql): array

    Returns an array of errors for the most recent MySQLi function call that can succeed or fail.

    Parameters

    mysql

    Procedural style only: A mysqli object returned by mysqli_connect() or mysqli_init()

    Return Values

    A list of errors, each as an associative array containing the errno, error, and sqlstate.

    Examples

    Example #1 $mysqli->error_list example

    Object-oriented style

    <?php
    $mysqli = new mysqli("localhost", "nobody", "");
    
    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    
    if (!$mysqli->query("SET a=1")) {
        print_r($mysqli->error_list);
    }
    
    /* close connection */
    $mysqli->close();
    ?>

    Procedural style

    <?php
    $link = mysqli_connect("localhost", "my_user", "my_password", "world");
    
    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    
    if (!mysqli_query($link, "SET a=1")) {
        print_r(mysqli_error_list($link));
    }
    
    /* close connection */
    mysqli_close($link);
    ?>

    The above examples will output:

    Array
    (
        [0] => Array
            (
                [errno] => 1193
                [sqlstate] => HY000
                [error] => Unknown system variable 'a'
            )
    
    )

    See Also

    • mysqli_connect_errno() - Returns the error code from last connect call
    • mysqli_connect_error() - Returns a description of the last connection error
    • mysqli_error() - Returns a string description of the last error
    • mysqli_sqlstate() - Returns the SQLSTATE error from previous MySQL operation

    Found A Problem?

    Learn How To Improve This Page • Submit a Pull Request • Report a Bug
    +add a note

    User Contributed Notes

    There are no user contributed notes for this page.
    • mysqli
      • $affected_​rows
      • autocommit
      • begin_​transaction
      • change_​user
      • character_​set_​name
      • close
      • commit
      • $connect_​errno
      • $connect_​error
      • _​_​construct
      • debug
      • dump_​debug_​info
      • $errno
      • $error
      • $error_​list
      • escape_​string
      • execute_​query
      • $field_​count
      • get_​charset
      • $client_​info
      • $client_​version
      • get_​connection_​stats
      • $host_​info
      • $protocol_​version
      • $server_​info
      • $server_​version
      • get_​warnings
      • $info
      • $insert_​id
      • more_​results
      • multi_​query
      • next_​result
      • options
      • poll
      • prepare
      • query
      • quote_​string
      • real_​connect
      • real_​escape_​string
      • real_​query
      • reap_​async_​query
      • release_​savepoint
      • rollback
      • savepoint
      • select_​db
      • set_​charset
      • set_​opt
      • $sqlstate
      • ssl_​set
      • stat
      • stmt_​init
      • store_​result
      • $thread_​id
      • thread_​safe
      • use_​result
      • $warning_​count
    • Deprecated
      • init
      • kill
      • ping
      • refresh
    You are visitor 01402639 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.