'fail', 'message' => '잘못된 요청']); exit; } try { $pdo = new PDO( "mysql:host=db;dbname=egbim;charset=utf8mb4", 'egbim','baron3840!!', [PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION] ); $pdo->exec("SET time_zone = '+09:00'"); // 댓글 소유자 확인 $st = $pdo->prepare("SELECT commenter FROM qa_comments WHERE comment_id = ?"); $st->execute([$commentId]); $row = $st->fetch(); if (!$row) { echo json_encode(['status'=>'fail','message'=>'존재하지 않는 댓글']); exit; } if ($row['commenter'] !== $loginId && !is_qna_admin()) { echo json_encode(['status'=>'fail','message'=>'본인 댓글만 삭제 가능']); exit; } // 삭제 $del = $pdo->prepare("DELETE FROM qa_comments WHERE comment_id = ?"); $del->execute([$commentId]); echo json_encode(['status'=>'ok']); } catch(Exception $e) { echo json_encode(['status'=>'fail','message'=>$e->getMessage()]); }