db에 데이터가 들어가지 않는데 이유를 알고 싶습니다. (아보카도 에디션)
contribute 라는 테이블 안에
contb_id ch_id ch_name contb_datetime contb_content contb_point contb_ch_contb contb_rel_action
이렇게 등록이 되어있고,
contribution_list.php 에
Copy
지급/회수
지급유형
개별지급
전체지급
캐릭터 이름필수
지급 내용필수
필수
contb_update.php에
Copy
$ch_id = $_POST['ch_id'];
$ch_name = $_POST['ch_name'];
$contb_point = $_POST['contb_point'];
$contb_content = $_POST['contb_content'];
$action = '획득';
if($contb_point 0) {
$action = '차감';
}
if($take_type == 'A') {
// 전체지급
$sql_common = " from {$g5['character_table']} ";
$sql_search = " where ch_state = '승인' ";
$sql = " select * {$sql_common} {$sql_search} ";
$result = sql_query($sql);
for($i=0; $ch = sql_fetch_array($result); $i++) {
if (($contb_point 0) && ($contb_point * (-1) > $ch['ch_contb'])) continue;
insert_contb($ch['ch_id'], $contb_point, "[정산]".$contb_content, $action);
}
} else {
// 개별지급
if(!$ch_id && $ch_name) {
$ch = sql_fetch("select ch_id, ch_name, ch_contb from {$g5['character_table']} where ch_name = '{$ch_name}'");
$ch_id = $ch['ch_id'];
} else {
$ch = sql_fetch("select ch_id, ch_name, ch_contb from {$g5['character_table']} where ch_id = '{$ch_id}'");
}
if (!$ch['ch_id'])
alert('존재하는 캐릭터가 아닙니다.');
if (($contb_point 0) && ($contb_point * (-1) > $ch['ch_contb']))
alert('경험치를 차감하는 경우 현재 경험치보다 작으면 안됩니다.');
insert_contb($ch['ch_id'], $contb_point, "[정산]".$contb_content, $action);
}
contn.lib.php 파일에는
Copy
function insert_contb($ch_id, $contb, $content='', $rel_action='')
{
global $config;
global $g5;
global $is_admin;
if ($contb == 0) { return 0; }
if ($ch_id == '') { return 0; }
$ch = get_character($ch_id);
if (!$ch['ch_id']) { return 0; }
// 캐릭터 경험치
$ch_contb = get_contb_sum($ch_id);
// 경험치 건별 생성
$contb_ch_contb = $ch_contb + $contb;
$sql = " insert into {$g5['contribute_table']}
set ch_id = '$ch_id',
ch_name = '{$ch['ch_name']}',
contb_datetime = '".G5_TIME_YMDHIS."',
contb_content = '".addslashes($content)."',
contb_point = '$contb',
contb_ch_contb = '$contb_ch_contb',
contb_rel_action = '$rel_action' ";
sql_query($sql);
// 경험치 UPDATE
$sql = " update {$g5['character_table']} set ch_contb = '$contb_ch_contb' where ch_id = '$ch_id' ";
sql_query($sql);
return 1;
}
// 경험치 내역 합계
function get_contb_sum($ch_id)
{
global $g5, $config;
// 포인트합
$sql = " select sum(contb_point) as sum_contb_point
from {$g5['contribute_table']}
where ch_id = '$ch_id' ";
$row = sql_fetch($sql);
return $row['sum_contb_point'];
}
이렇게 코드 작성을 해놨습니다.
그런데 맨 위 해당 db에 데이터가 들어가지 않아요... 왜 그럴까요?
답변 2개
1년 전
쿼리를 echo 로 찍으신 후 그 쿼리문을 직접 phpmyadmin 이나 db 외부 프로그램을 이용해서 직접 해보는 방법 외에는 sql_query($sql) or die (mysql_error()); 을 찍어보셔야 하는데....
직접 보는게 더 낫습니다.
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
1년 전
$sql = " insert into {$g5['contribute_table']}
set ch_id = '$ch_id',
ch_name = '{$ch['ch_name']}',
contb_datetime = '".G5_TIME_YMDHIS."',
contb_content = '".addslashes($content)."',
contb_point = '$contb',
contb_ch_contb = '$contb_ch_contb',
contb_rel_action = '$rel_action' ";
sql_query($sql);
해당 부분의 쿼리를 찍어서 해당 쿼리를 db에서 직접쿼리를 실행해서 확인해 보세요
제대로 쿼리가 실행되는거라면 등록되어야 하는게 맞습니다.
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인