'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) { echo json_encode(['status'=>'fail','message'=>'본인 댓글만 수정 가능']); exit; } // 업데이트 $up = $pdo->prepare("UPDATE qa_comments SET content=?, updated_at=NOW() WHERE comment_id=?"); $up->execute([$newComment, $commentId]); echo json_encode(['status'=>'ok']); } catch(Exception $e) { echo json_encode(['status'=>'fail','message'=>$e->getMessage()]); }