遇到MYSQL查询问题

My function gets $status (0-error, 1-success), $err_id (id of error message in db) and $field (name of input field) variable and fetches error message from db, with given vars.

Tried die() in every step to detect where error occuring, also placed die($status.$err_id.$field); right after function err. No success.

Debuged with netbeans. Marked the line in which debug stops in function

$msg is always null. Can't fetch it from db. There is no error in php error log. May be my code has mistake? Please take a look.

function err($status, $err_id = 0, $field = 0)
{
        global $db;
        if ($status == 0) {
                $stmt = $db->prepare("SELECT msg FROM err_msgs WHERE field = ? AND id= ?") or die(htmlspecialchars($db->error));
                $stmt->bind_param("si", $field, $err_id) or die(htmlspecialchars($stmt->error));
                $stmt->execute() or die(htmlspecialchars($stmt->error));
                $stmt->bind_result($msg) or die(htmlspecialchars($stmt->error));

                >>debug stops here>> $stmt->fetch() or die(htmlspecialchars($stmt->error));

                response('error', $msg);
                $stmt->close();
                die();

        } else {
                response('success', 'Success!');

        }

}

I forgot to fetch after binding result

$stmt->fetch()

try switching these two lines:

$stmt->execute() or die(htmlspecialchars($stmt->error)); 
$stmt->bind_result($msg) or die(htmlspecialchars($stmt->error));

to

$stmt->bind_result($msg) or die(htmlspecialchars($stmt->error)); 
$stmt->execute() or die(htmlspecialchars($stmt->error));