Get the last error description for the most recent function call, if any in PHP

Description

The following code shows how to get the last error description for the most recent function call, if any.

Example


/* w w w.j  a va2 s . 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 ('XML')")){
        echo("Error description: " . mysqli_error($con));
    }

    mysqli_close($con);
?>




















Home »
  PHP Tutorial »
    MySQL »




MySQLi
MySQLi Object Oriented