Fatal error: Call to undefined method mysqli::error() [duplicate]

For those who stumbled on this page.

The error you get from

Fatal error: Call to undefined method mysqli::error()

This is because we need to access the error as variable not as function

so the correct code is

if(! empty( $mysqli->error ) ){
   echo $mysqli->error;  // <- this is not a function call error()
}