<p>I am new to mysqli, and trying to confirm that if I so something like the below, the errno will be set to the last error, if any, and not the error of the last query. </p>

<p>Is this a decent practice or should I be checking for the error in between every query?</p>

<p>Thanks! </p>

<pre><code>$mysqli-&gt;autocommit(FALSE);

$mysqli-&gt;query("INSERT INTO .....");
$mysqli-&gt;query("INSERT INTO .....");
$mysqli-&gt;query("INSERT INTO .....");
$mysqli-&gt;query("INSERT INTO .....");
$mysqli-&gt;query("INSERT INTO .....");

if ( 0==$mysqli-&gt;errno ) {
    $mysqli-&gt;commit();
} else {
    $mysqli-&gt;rollback();
    // Handle error
}
</code></pre>

No -- it reports the error code of the last mysqli function call.  Zero means no error occurred on the last function call.  So if one in the middle fails, you won't know about it by checking only at the end.
In other words, yes, you need to check the error code after each function call.  Note that an error is indicated by the return value of
```
$mysqli->query()
```
as well.  Paraphrasing the example from the
mysqli_errno
doc:
```
```
if (!$mysqli->query("INSERT ...")) {
    printf("Errorcode: %d\n", $mysqli->errno);
}
```
```