Get a list of errors for the most recent function call, if any in PHP

Description

The following code shows how to get a list of errors for the most recent function call, if any.

Example


/*ww  w  . j  a  v a2s . c o m*/
<?php
    $con=mysqli_connect("localhost","root","","test");
    // Check connection
    if (mysqli_connect_errno()){
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    // Perform a query, check for error
    if (!mysqli_query($con,"INSERT INTO employee (Name) VALUES ('newName')")){
        print_r(mysqli_error_list($con));
    }

    mysqli_close($con);
?>




















Home »
  PHP Tutorial »
    MySQL »




MySQLi
MySQLi Object Oriented