db에 데이터가 들어가지 않는데 이유를 알고 싶습니다. (아보카도 에디션)

db에 데이터가 들어가지 않는데 이유를 알고 싶습니다. (아보카도 에디션)

QA

db에 데이터가 들어가지 않는데 이유를 알고 싶습니다. (아보카도 에디션)

답변 2

본문

contribute 라는 테이블 안에 

 

contb_id    ch_id    ch_name    contb_datetime    contb_content    contb_point    contb_ch_contb    contb_rel_action

 

 

이렇게 등록이 되어있고,

 

contribution_list.php 에 

 


 
<form name="fpointlist2" method="post" id="fpointlist2" action="./contb_update.php" autocomplete="off">
    <input type="hidden" name="sfl" value="<?php echo $sfl ?>">
    <input type="hidden" name="stx" value="<?php echo $stx ?>">
    <input type="hidden" name="sst" value="<?php echo $sst ?>">
    <input type="hidden" name="sod" value="<?php echo $sod ?>">
    <input type="hidden" name="page" value="<?php echo $page ?>">
    <input type="hidden" name="token" value="<?php echo $token ?>">
 
    <section id="anc_001">
        <h2 class="h2_frm"><?=$config['cf_contribute_name']?> 지급/회수</h2>
        <?php echo $pg_anchor ?>
 
        <div class="tbl_frm01 tbl_wrap">
            <div class="tbl_frm01 tbl_wrap">
                <table>
                    <colgroup>
                        <col style="width: 120px;">
                        <col>
                    </colgroup>
                    <tbody>
                        <tr>
                            <th scope="row">지급유형</th>
                            <td>
                                <input type="radio" id="take_type_01" name="take_type" value="P" checked
                                    onclick="if(document.getElementById('take_type_01').checked) $('#take_member_name').show();" />
                                <label for="take_type_01">개별지급</label>
                                  
                                <input type="radio" id="take_type_02" name="take_type" value="A"
                                    onclick="if(document.getElementById('take_type_02').checked) $('#take_member_name').hide();" />
                                <label for="take_type_02">전체지급</label>
                            </td>
                        </tr>
                        <tr id="take_member_name">
                            <th scope="row"><label for="ch_name">캐릭터 이름<strong class="sound_only">필수</strong></label>
                            </th>
                            <td>
                                <input type="hidden" name="ch_id" id="ch_id" value="" />
                                <input type="text" name="ch_name" value="" id="ch_name"
                                    onkeyup="get_ajax_character(this, 'character_list', 'ch_id');" />
                                <div id="character_list" class="ajax-list-box">
                                    <div class="list"></div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="contb_content">지급 내용<strong
                                        class="sound_only">필수</strong></label>
                            </th>
                            <td><input type="text" name="contb_content" id="contb_content" required
                                    class="required frm_input" size="80"></td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="contb_point"><?=$config['cf_contribute_name']?><strong
                                        class="sound_only">필수</strong></label></th>
                            <td><input type="text" name="contb_point" id="contb_point" required
                                    class="required frm_input">
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
 
    </section>
 
    <div class="btn_confirm01 btn_confirm">
        <input type="submit" value="확인" class="btn_submit">
    </div>
</form>

 

 

contb_update.php에

 


$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 파일에는 


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

$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에서 직접쿼리를 실행해서 확인해 보세요

제대로 쿼리가 실행되는거라면 등록되어야 하는게 맞습니다.

쿼리를 echo 로 찍으신 후 그 쿼리문을 직접 phpmyadmin 이나 db 외부 프로그램을 이용해서 직접 해보는 방법 외에는 sql_query($sql) or die (mysql_error()); 을 찍어보셔야 하는데....

 

직접 보는게 더 낫습니다.

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 0
© SIRSOFT
현재 페이지 제일 처음으로