SQLSTATE [42000]:语法错误或访问冲突:打开页面时出现1064错误

when we try to open our inbox page to reply it show error

Syntax error or access violation 1064

You have an error in your SQL syntax check the manual that corresponds to your MySQL server

Please help to solve this problem.

public function reply($id)
{
    $user_id = \Auth::id();

    $inbox = collect(DB::select("select i.id,i.subject,i.is_read,i.user_id,i.sent_to,i.type,i.msg,i.created_at,u.name,u.email from inboxes as i INNER JOIN users as u on u.id = i.user_id WHERE i.`id`= $id"))->first();
    $reply = DB::select("select ir.*,u.name,u.email from inbox_replies as ir INNER JOIN users as u on u.id = ir.user_id WHERE ir.`inbox_id`= $inbox->id");

    if ($inbox->is_read == '1') {
        DB::update("update inboxes set `is_read`=?,updated_at=now() where id=?", ['2', $id]);
    }

    $sent_to = '';
    if ($inbox->type == '2') {
        if ($user_id == $inbox->user_id) {
            $sent_to = $inbox->sent_to;
        } elseif ($user_id == $inbox->sent_to) {
            $sent_to = $inbox->user_id;
        }
    } else {
        $sent_to = $reply[0]->user_id;
    }

    $u = InboxesController::getUserDetail($sent_to);
    $u_email = $u->email;
    $u_name = $u->name;

    $sender_info = collect(DB::select("select email,name from users WHERE `id`= $user_id"))->first();

    return view('admin.inbox.edit', compact('inbox', 'reply', 'u_email', 'u_name', 'user_id', 'sender_info', 'sent_to'));
}

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 (SQL: select email,name from users WHERE id= ) {"userId":14,"email":"foo@foo.in","exception":"[object] (Illuminate\Database\QueryException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 (SQL: select email,name from users WHERE id= ) at /home/foo/public_html/locale/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at /home/foo/public_html/locale/vendor/laravel/framework/src/Illuminate/Database/Connection.php:326)