장바구니를 활용한 견적서 출력에서 lib파일 오류?

장바구니를 활용한 견적서 출력에서 lib파일 오류?

QA

장바구니를 활용한 견적서 출력에서 lib파일 오류?

본문

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in /www_root/lib/common.lib.php on line 1692

 

이에러는 어떻게 해결해야할까요....? 

 

장바구니에서 견적서를 출력하는 구문을 제작하려하는데,

 


<?php
include_once('./_common.php');
include_once(G5_PATH.'/head.sub.php');

//print_r($_GET);
print_r($_POST);
print_r($_res);
# 세션데이터에서 장바구니 전송값을 가져온다. ---------------------------------------------------
# [cart.php -> ajax.cartprint.php 세션저장한 값]
$tmp_data = get_session("cartprint");
if($tmp_data) {
    $array = unserialize($tmp_data);
}
//print_r($array);
# 장바구니 데이터 검사 --------------------------------------------------------------------------
if(is_array($array) && is_array($array['it_id']) && is_array($array['ct_chk'])) {
    # 장바구니 전송됨
} else {
    # 장바구니 전송안됨
    echo "<h2>견적서를 출력할 제품이 없습니다.</h2>";
    include_once(G5_PATH.'/tail.sub.php');
    exit;
}

# 장바구니 no 가공 ---------------------------------------------------------------------------
/* 장바구니 상품번호와 체크여부(ct_chk)를 비교하여 견적할 제품번호만 남긴다. */
    foreach($array['it_id'] as $key=>$val) {
    if(isset($array['ct_chk'][$key]) && $array['ct_chk'][$key]=="1") {
        $TMP['it'][] = $val;
    } else {
        continue;
    }
}
//print_r($TMP['it']);
if(is_array($TMP['it']) && is_array($TMP['it'])) {
    # 견적할 제품이 있음
} else {
    # 견적할 제품이 없음
    echo "<h2>견적서를 출력할 제품이 없습니다.</h2>";
    include_once(G5_PATH.'/tail.sub.php');
    exit;
}

# 장바구니 DB 가져오기 ---------------------------------------------------------------------------
$s_cart_id = get_session('ss_cart_id');
// $s_cart_id 로 현재 장바구니 자료 쿼리
$qry = " SELECT * FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$s_cart_id' AND it_id IN ( ". implode(",", $TMP['it']) ." ) ORDER BY it_id ";
$res = sql_query($qry);
if(sql_num_rows($res)>0) {
    $idx = 0;
    while($row = sql_fetch_array($res)) {
        $DATA['cart'][$idx] = $row;
        # 옵션DB 가져오기
        $qry2 = " SELECT * FROM {$g5['g5_shop_item_option_table']} WHERE it_id = '{$row['it_id']}' AND io_id='{$row['io_id']}' AND io_type='0' ";
        $res2 = sql_query($qry2);
        if(sql_num_rows($res2)>0) {
            $DATA['opt'][$idx] = sql_fetch_array($res2);
        }
        $idx++;
    }
}
//print_r($DATA);

# 출력화면 그리기      ---------------------------------------------------------------------------
?>

<style type="text/css">
.print-wrap { width:600px; box-sizing:border-box; margin:5px auto; }
/* 표제부 */
.table-info { border-collapse:collapse; width:100%; }
.table-info * { font-size: 12px;}
.table-info td { border:1px solid #09a4b6; height:20px; }
.table-info .td-row-6 { background:#06899f; color:#ffffff; text-align:center; }
.table-info .td-head { background:#67b9c2; text-align:center; color:#ffffff; }
/* 제품리스트 */
.table-list { border-collapse:collapse; width:100%; margin:20px 0 0 0; }
.table-list * { font-size:12px;}
.table-list td { border:1px solid #09a4b6; height:20px; }
.table-list .td-head { background:#67b9c2; text-align:center; color:#ffffff; }
.table-list .td-body { font-size:11px !important; }
/* 공통 */
.input-1 { width:174px; }
.td-right { text-align:right; }
.td-center { text-align:center; }
/* 기타 */
.div-help { margin:10px 0; color:#2861c8; }
.print-button { width:600px; margin:10px auto; text-align:right; }
.print-button button { padding:4px 10px; background:#2548a5; color:#ffffff; border:0; }
@media print {
    .print-button { display:none; }
}
</style>
<div class="print-wrap">
    <table class="table-info">
    <col width="20">
    <col width="60">
    <col width="180">
    <col width="20">
    <col width="60">
    <col width="">
    <col width="60">
    <col width="">
    <tr>
        <td class="td-row-6" rowspan="6">의<br>뢰<br>자</td>
        <td class="td-head">견적일</td>
        <td class="td-body"><input type="text" class="input-1" value="<?=date("Y-m-d")?>"></td>
        <td class="td-row-6" rowspan="6">공<br>급<br>자</td>
        <td class="td-head">등록번호</td>
        <td class="td-body" colspan="3"><?=$default['de_admin_company_saupja_no']?></td>
    </tr>
    <tr>
        <td class="td-head">업체명</td>
        <td class="td-body"><input type="text" class="input-1"></td>
        <td class="td-head">회사명</td>
        <td class="td-body"><?=$default['de_admin_company_name']?></td>
        <td class="td-head">성명</td>
        <td class="td-body"><?=$default['de_admin_company_owner']?></td>
    </tr>
    <tr>
        <td class="td-head">담당자</td>
        <td class="td-body"><input type="text" class="input-1"></td>
        <td class="td-head">주소</td>
        <td class="td-body" colspan="3"><?=$default['de_admin_company_addr']?></td>
    </tr>
    <tr>
        <td class="td-head">전화</td>
        <td class="td-body"><input type="text" class="input-1"></td>
        <td class="td-head">업태</td>
        <td class="td-body"><?=$default['de_biztype_a']?></td>
        <td class="td-head">종목</td>
        <td class="td-body"><?=$default['de_biztype_b']?></td>
    </tr>
    <tr>
        <td class="td-head">팩스</td>
        <td class="td-body"><input type="text" class="input-1"></td>
        <td class="td-head">전화</td>
        <td class="td-body"><?=$default['de_admin_company_tel']?></td>
        <td class="td-head">팩스</td>
        <td class="td-body"><?=$default['de_admin_company_fax']?></td>
    </tr>
    <tr>
        <td class="td-head">E-mail</td>
        <td class="td-body"><input type="text" class="input-1"></td>
        <td class="td-head">담당자</td>
        <td class="td-body" colspan="3"></td>
    </tr>
    </table>
    <table class="table-list">
    <col width="80">
    <col width="80">
    <col width="80">
    <col width="">
    <col width="60">
    <col width="40">
    <col width="70">
    <tr>
        <td class="td-head">제품번호</td>
        <td class="td-head">제품명</td>
        <td class="td-head">형식번호</td>
        <td class="td-head">제품사양</td>
        <td class="td-head">단가</td>
        <td class="td-head">수량</td>
        <td class="td-head">가격</td>
    </tr>
    <?
    $total_price = 0;
    $this_price = 0;
                                   
   if (isset($DATA['cart']) && is_array($DATA['cart'])) {                                
    foreach($DATA['cart'] as $key=>$val) {
        $this_price = ($val['ct_price']+$val['io_price']) * $val['ct_qty'];
        $total_price += $this_price;
        
    ?>
    <tr>
        <td class="td-body"><?php $val['io_id']?></td>
        <td class="td-body"><?php $val['it_name']?></td>
        <td class="td-body"><?php $DATA['opt'][$key]['io_misc01']?></td>
        <td class="td-body"><?php $DATA['opt'][$key]['io_misc02']?></td>
        <td class="td-body td-right"><?=number_format($val['ct_price']+$val['io_price'])?></td>
        <td class="td-body td-center"><?=number_format($val['ct_qty'])?></td>
        <td class="td-body td-right"><?=number_format($this_price)?></td>
    </tr>
    
    
    <?
    } # end of if 
       } # end foreach;
    ?>
    <tr>
        <td class="td-body td-center" colspan="6"><strong>합계금액</strong></td>
        <td class="td-body td-right"><strong><?=number_format($total_price)?></strong></td>
    </tr>

    </table>
    <div class="div-help">
        상기 견적내용은 환율에 따라 가격이 변동될 수 있으니 참고용으로만 활용하시기 바랍니다.<br>
        (견적내용 및 입력사항은 서버로 전송되지 않습니다)<br>
        자세한 견적상담을 원하시면 <?=$default['de_admin_company_tel']?>로 전화바랍니다.
    </div>
</div>
<div class="print-button">
    <button type="button" onClick="print();">인쇄</button>
    <button type="button" onClick="window.close();">닫기</button>
</div>
<?
include_once(G5_PATH.'/tail.sub.php');
?>

 

여기서 에러가 나오고 있습닏 ㅏㅠ

이 질문에 댓글 쓰기 :

답변 1

$qry = " SELECT * FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$s_cart_id' AND it_id IN ( ". implode(",", $TMP['it']) ." ) ORDER BY it_id ";

위 쿼리를 실행하면 에러가 나기 때문에..

 

다음 코드

$res = sql_query($qry);
if(sql_num_rows($res)>0) {

에서 레코드 갯수를 가져오는 부분에서도 에러가 난 것입니다.

 

$qry = " SELECT * FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$s_cart_id' AND it_id IN ( ". implode(",", $TMP['it']) ." ) ORDER BY it_id ";

->

$qry = " SELECT * FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$s_cart_id' AND it_id IN ( '". implode("','", $TMP['it']) ."' ) ORDER BY it_id ";

답변을 작성하시기 전에 로그인 해주세요.
전체 123,535 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT