채택완료

게시판 이동시 업데이트 할때 추가 작업하려고 합니다.

2017-04-17 (월) 14:25:37 6,756

게시판 이동시 wr_17필드에 신규라고 되어있으면, 두 개의 테이블에 wr_17을 기존이라고 update 바꾸려고 하는데 반응이 없어서요..이동하는데에는 문제가 없지만, 혹시나 싶어 echo로 wr_id,code,wr_subject,sca를 출력해보니까 선택한 것에 대해 제대로 나오긴 하거든요..

무엇이 잘못 되었을까요??ㅠㅠ

$wr_id = $_GET['wr_id'];
$wr_subject = $_GET['wr_subject'];
$code = $_GET['code'];
$sca = $_GET['sca']; 

$res2 = sql_fetch("select * from g5_write_bbt_ext where wr_subject = '$wr_subject' and ca_name='$sca'");
if($res2['wr_17'] == "신규") {

$add_wr_17 = "기존";

$sql2 = " update g5_write_cam_list set
   wr_17 = '$add_wr_17' //echo로 찍으면 값이 정상적으로 나옵니다.
  where code='{$code}' and wr_subject='{$wr_subject}' and ca_name='{$sca}'";
sql_query($sql2);  //업데이트할 1번째 테이블

$sql3 = " update g5_write_FIXTURE set
   wr_17 = '$add_wr_17'
  where code='{$code}' and wr_subject='{$wr_subject}' and ca_name='{$sca}'";
sql_query($sql3); //업데이트할 2번째 테이블

}

|

답변 2개 / 댓글 2개

채택된 답변
+20 포인트

echo 로 $wr_17을 찍어보지마시고

echo $sql; exit; 이런식으로 쿼리문을 찍어보세요

답변에 대한 댓글 1개

echo $sql2로도 해봤는데요..~~~~~ wr_17='기존' and wr_subject='~~~' and 등등 출력값은
나오는데 update가 안되요..

업데이트가 안되면 어떠한 이유때문에 안되는것이죠.

sql_query($sql2, true); 이렇게 해서 에러가 나는지 확인해보셔야죠.

아래코드처럼 해서 에러가 나는지 안나는지부터 확인해보세요.

Copy
$wr_id = $_GET['wr_id'];$wr_subject = $_GET['wr_subject'];$code = $_GET['code'];$sca = $_GET['sca'];  $res2 = sql_fetch("select * from g5_write_bbt_ext where wr_subject = '$wr_subject' and ca_name='$sca'"); if($res2['wr_17'] == "신규") {$add_wr_17 = "기존";$sql2 = " update g5_write_cam_list set    wr_17 = '$add_wr_17' //echo로 찍으면 값이 정상적으로 나옵니다.  where code='{$code}' and wr_subject='{$wr_subject}' and ca_name='{$sca}'";sql_query($sql2, true);  //업데이트할 1번째 테이블$sql3 = " update g5_write_FIXTURE set    wr_17 = '$add_wr_17'  where code='{$code}' and wr_subject='{$wr_subject}' and ca_name='{$sca}'";sql_query($sql3, true); //업데이트할 2번째 테이블 exit;}

답변에 대한 댓글 1개

말씀하신대로 했지만 아무 에러가 없습니다.ㅠㅠ

답변을 작성하려면 로그인이 필요합니다.