Mysql문의
본문
<?php
include_once "**********";
$how = $_GET['how'];
$times = time();
$Bids = $_GET['Bids'];
$Sno = $_GET['Sno'];
$memoSno = $_GET['memoSno'];
$contents = $_GET['contents'];
print_r($_GET);
if($how == "reple"){
$A = "INSERT INTO `alertmemo` (`memoSno`,`times`,`bid`,`sno`,`contents`)
VALUES (`".$memoSno."`,`".$times."`,`".$Bids."`,`".$Sno."`,`".$contents."`)";
mysqli_query($conn,$A)or die(mysqli_error());
} // 답글에 댓글
else if($how == "edit"){
} // 수정
else if($how == "delete"){
$A = "DELETE FROM alertmemo WHERE memoSno=`".$memoSno."`";
mysqli_query($conn,$A);
} // 삭제
else if($how == "write"){
$A = "INSERT INTO alertmemo ('contents','times','bid','sno','memoSno') VALUES ('".$contents."','".$times."','".$Bids."','".$Sno."','".$memoSno."')";
mysqli_query($conn,$A);
print mysqli_error($conn);
} //댓글 작성
?>
위소스를 돌리면 아래 오류가 뿜어져 나오는데요 어디가 잘못 되 었 을 까요?
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 ''contents','times','bid','sno','memoSno') VALUES ('test','1660806739','TNBreview' at line 1
답변 2
// $A = "INSERT INTO alertmemo ('contents','times','bid','sno','memoSno') VALUES ('".$contents."','".$times."','".$Bids."','".$Sno."','".$memoSno."')";
$A = "INSERT INTO alertmemo (`contents`,`times`,`bid`,`sno`,`memoSno`) VALUES ('".$contents."','".$times."','".$Bids."','".$Sno."','".$memoSno."')";
백틱으로 바꿔보세요
!-->쿼리에 홑따옴표 쌍따옴표 같이 쓸필요가 없을텐데요..
그냥
$A = "INSERT INTO alertmemo ('contents','times','bid','sno','memoSno') VALUES ('$contents','$times','$Bids','$Sno','$memoSno')";
답변을 작성하시기 전에 로그인 해주세요.