Php没有回应Mysqli db错误

Is there something I need to set in php to make it display mysqli prepared statement errors?

$stmt = $db->prepare("my query string...");

if ( false===$stmt ) {
  echo $db->error;
}

It echoes nothing.

I needed to make $db global in the function. It works now!

Do you sure that there are errors? Just add to output any string. For example

if ( false===$stmt ) {
  echo "Prepare error:" . $db->error;
}
if (!($stmt = $mysqli->prepare("INSERT INTO test(id) VALUES (?)"))) {
echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}

something like that. source : http://php.net/manual/en/mysqli.quickstart.prepared-statements.php