dongya2029 2019-08-02 07:28
浏览 780

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)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 个人网站被恶意大量访问,怎么办
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制