shop 검색 오류

shop 검색 오류

QA

shop 검색 오류

본문

검색을 하면

search.php 화면에 

Warning: Division by zero in /home/hosting_users/kodaecsnew/www/mobile/shop/search.php on line 120라는 오류가 뜹니다ㅠ..

오류뜬 곳은 $total_page  = ceil($total_count / $items); 인데ㅠ.....

 

처음에 게시판검색 소스를 긁어서 썼다가 쇼핑몰 검색으로 수정한건데 수정이 잘 안된것같아요

 

이건 검색창있는 헤드에 들어간 소스고요.


                    <div id="hd_sch" class="hd_div">
                        <h2>사이트 내 전체검색</h2>
                        <form name="frmsearchbox" 
                        action="<?php echo G5_SHOP_URL; ?>/search.php" onsubmit="return search_submit(this);" 
                        method="get">
                            <input type="hidden" name="sfl" value="wr_subject||wr_content">
                            <input type="hidden" name="sop" value="and">
                            <input type="text" name="stx" id="sch_stx" placeholder="검색어(필수)" required class="required" maxlength="20">
                            <input type="submit" value="검색" id="sch_submit">
                        </form>
                    </div>
                    <script>
                    function fsearchbox_submit(f)
                    {
                        if (f.stx.value.length < 2) {
                            alert("검색어는 두글자 이상 입력하십시오.");
                            f.stx.select();
                            f.stx.focus();
                            return false;
                        }
                        // 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.
                        var cnt = 0;
                        for (var i=0; i<f.stx.value.length; i++) {
                            if (f.stx.value.charAt(i) == ' ')
                                cnt++;
                        }
                        if (cnt > 1) {
                            alert("빠른 검색을 위하여 검색어에 공백은 한개만 입력할 수 있습니다.");
                            f.stx.select();
                            f.stx.focus();
                            return false;
                        }
                        return true;
                    }
                    </script>

 

이건 mobile/shop/search.php에 들어있는 소스입니다.


<?php
include_once('./_common.php');
$g5['title'] = '전체검색 결과';
include_once('./_head.php');
// QUERY 문에 공통적으로 들어가는 내용
// 상품명에 검색어가 포한된것과 상품판매가능인것만
$sql_common = " from {$g5['g5_shop_item_table']} a, {$g5['g5_shop_category_table']} b ";
$where = array();
$where[] = " (a.ca_id = b.ca_id and a.it_use = 1 and b.ca_use = 1) ";
$search_all = true;
// 상세검색 이라면
if (isset($_GET['qname']) || isset($_GET['qexplan']) || isset($_GET['qid']) || isset($_GET['qbasic']))
    $search_all = false;
$q       = utf8_strcut(get_search_string(trim($_GET['q'])), 30, "");
$qname   = isset($_GET['qname']) ? trim($_GET['qname']) : '';
$qexplan = isset($_GET['qexplan']) ? trim($_GET['qexplan']) : '';
$qid     = isset($_GET['qid']) ? trim($_GET['qid']) : '';
$qbasic  = isset($_GET['qbasic']) ? trim($_GET['qbasic']) : '';
$qcaid   = isset($_GET['qcaid']) ? preg_replace('#[^a-z0-9]#i', '', trim($_GET['qcaid'])) : '';
$qfrom   = isset($_GET['qfrom']) ? preg_replace('/[^0-9]/', '', trim($_GET['qfrom'])) : '';
$qto     = isset($_GET['qto']) ? preg_replace('/[^0-9]/', '', trim($_GET['qto'])) : '';
if (isset($_GET['qsort']))  {
    $qsort = trim($_GET['qsort']);
    $qsort = preg_replace("/[\<\>\'\"\\\'\\\"\%\=\(\)\s]/", "", $qsort);
} else {
    $qsort = '';
}
if (isset($_GET['qorder']))  {
    $qorder = preg_match("/^(asc|desc)$/i", $qorder) ? $qorder : '';
} else {
    $qorder = '';
}
if(!($qname || $qexplan || $qid || $qbasic))
    $search_all = true;
// 검색범위 checkbox 처리
$qname_check = false;
$qexplan_check = false;
$qid_check = false;
$qbasic_check = false;
if($search_all) {
    $qname_check = true;
    $qexplan_check = true;
    $qid_check = true;
    $qbasic_check = true;
} else {
    if($qname)
        $qname_check = true;
    if($qexplan)
        $qexplan_check = true;
    if($qid)
        $qid_check = true;
    if($qbasic)
        $qbasic_check = true;
}
if ($q) {
    $arr = explode(" ", $q);
    $detail_where = array();
    for ($i=0; $i<count($arr); $i++) {
        $word = trim($arr[$i]);
        if (!$word) continue;
        $concat = array();
        if ($search_all || $qname)
            $concat[] = "a.it_name";
        if ($search_all || $qexplan)
            $concat[] = "a.it_explan2";
        if ($search_all || $qid)
            $concat[] = "a.it_id";
        if ($search_all || $qbasic)
            $concat[] = "a.it_basic";
        $concat_fields = "concat(".implode(",' ',",$concat).")";
        $detail_where[] = $concat_fields." like '%$word%' ";
        // 인기검색어
        insert_popular($concat, $word);
    }
    $where[] = "(".implode(" and ", $detail_where).")";
}
if ($qcaid)
    $where[] = " a.ca_id like '$qcaid%' ";
if ($qfrom && $qto)
    $where[] = " a.it_price between '$qfrom' and '$qto' ";
$sql_where = " where " . implode(" and ", $where);
// 상품 출력순서가 있다면
$qsort  = strtolower($qsort);
$qorder = strtolower($qorder);
$order_by = "";
// 아래의 $qsort 필드만 정렬이 가능하게 하여 다른 필드로 하여금 유추해 볼수 없게함
if (($qsort == "it_sum_qty" || $qsort == "it_price" || $qsort == "it_use_avg" || $qsort == "it_use_cnt" || $qsort == "it_update_time") &&
    ($qorder == "asc" || $qorder == "desc")) {
    $order_by = ' order by ' . $qsort . ' ' . $qorder . ' , it_order, it_id desc';
}
// 총몇개 = 한줄에 몇개 * 몇줄
$items = $default['de_mobile_search_list_mod'] * $default['de_mobile_search_list_row'];
// 페이지가 없으면 첫 페이지 (1 페이지)
if ($page < 1) $page = 1;
// 시작 레코드 구함
$from_record = ($page - 1) * $items;
// 검색된 내용이 몇행인지를 얻는다
$sql = " select COUNT(*) as cnt $sql_common $sql_where ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$total_page  = ceil($total_count / $items); // 전체 페이지 계산
$sql = " select b.ca_id, b.ca_name, count(*) as cnt $sql_common $sql_where group by b.ca_id order by b.ca_id ";
$result = sql_query($sql);
$categorys = array();
// 검색된 분류를 배열에 저장
while($row = sql_fetch_array($result)){
    $categorys[] = $row;
}
$search_skin = G5_MSHOP_SKIN_PATH.'/search.skin.php';
if(!file_exists($search_skin)) {
    echo str_replace(G5_PATH.'/', '', $search_skin).' 스킨 파일이 존재하지 않습니다.';
} else {
    include_once($search_skin);
}
include_once('./_tail.php');
?>

 

반응형이라 다 모바일로 설정되어있어요.

 

제가 영카트5랑 그누보드5를 쓴지 한달 막 지난 왕초보라 쉽게 설명해주실 고수님 찾습니다ㅠ.... 

이 질문에 댓글 쓰기 :

답변 1

관리자 페이지 --> 쇼핑몰설정 --> 모바일 검색상품출력 에서 입력값을 제대로 넣으세요

 

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

회원로그인

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