모바일에서 장바구니 담기 에러

모바일에서 장바구니 담기 에러

QA

모바일에서 장바구니 담기 에러

본문

http://www.butterfly-korea.co.kr/shop/shop/index.php?device=mobile

 

아이디 test1

 

비밀번호 1234

 

로 로그인해서 장바구니 담으려고 하면,

 

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/hosting_users/to_love58/www/shop/lib/common.lib.php on line 1563

  • 장바구니에 담긴 상품이 없습니다.

이렇게 나오는데, 무슨 문제 인가요?

 

 

function sql_num_rows($result)
{
    if(function_exists('mysqli_num_rows') && G5_MYSQLI_USE)
        return mysqli_num_rows($result);   // << 이부분이 1563 번째 줄인데 무슨 이윤지 모르겠네요. ㅜㅜ
    else
        return mysql_num_rows($result);

이 질문에 댓글 쓰기 :

답변 2

위 오류는 mysql_query 결과를 mysqli_num_rows 함수에 넘겨줄 때 발생합니다.

코드 상에서 $result = mysql_query($sql); 와 유사한 코드가 있는지 확인해 보시기 바랍니다.

 

또는 쿼리문에 오류가 있어 결과값이 false 등일 때도 발생할 수 있습니다.

이 때는 sql_query($sql, true); 와 같이 수정하여 쿼리 오류를 확인할 수 있습니다.

$result = mysql_query($sql);

이건 없구요. 유사한걸로

$result = @mysql_query

1462라인에

// mysqli_query 와 mysqli_error 를 한꺼번에 처리
// mysql connect resource 지정 - 명랑폐인님 제안
function sql_query($sql, $error=G5_DISPLAY_SQL_ERROR, $link=null)
{
    global $g5;

    if(!$link)
        $link = $g5['connect_db'];

    // Blind SQL Injection 취약점 해결
    $sql = trim($sql);
    // union의 사용을 허락하지 않습니다.
    //$sql = preg_replace("#^select.*from.*union.*#i", "select 1", $sql);
    $sql = preg_replace("#^select.*from.*[\s\(]+union[\s\)]+.*#i ", "select 1", $sql);
    // `information_schema` DB로의 접근을 허락하지 않습니다.
    $sql = preg_replace("#^select.*from.*where.*`?information_schema`?.*#i", "select 1", $sql);

    if(function_exists('mysqli_query') && G5_MYSQLI_USE) {
        if ($error) {
            $result = @mysqli_query($link, $sql) or die("<p>$sql<p>" . mysqli_errno($link) . " : " .  mysqli_error($link) . "<p>error file : {$_SERVER['SCRIPT_NAME']}");
        } else {
            $result = @mysqli_query($link, $sql);
        }
    } else {
        if ($error) {
            $result = @mysql_query($sql, $link) or die("<p>$sql<p>" . mysql_errno() . " : " .  mysql_error() . "<p>error file : {$_SERVER['SCRIPT_NAME']}");
        } else {
            $result = @mysql_query($sql, $link);
        }
    }

    return $result;
}

이런게 있어요.

이곳 문제 인가요?

이미 답 나왔네요.
$result = @mysql_query
이걸
$result = sql_query
이걸로 바꿔보세요.

편리님 답변대로 mysql_query()의 결과를 mysqli_num_rows()로 넘겨줘서 그런거니 mysqli_query()가 동작하도록 sql_query()를 사용하시면 됩니다.

// mysqli_query 와 mysqli_error 를 한꺼번에 처리
// mysql connect resource 지정 - 명랑폐인님 제안
function sql_query($sql, $error=G5_DISPLAY_SQL_ERROR, $link=null)
{
    global $g5;

    if(!$link)
        $link = $g5['connect_db'];

    // Blind SQL Injection 취약점 해결
    $sql = trim($sql);
    // union의 사용을 허락하지 않습니다.
    //$sql = preg_replace("#^select.*from.*union.*#i", "select 1", $sql);
    $sql = preg_replace("#^select.*from.*[\s\(]+union[\s\)]+.*#i ", "select 1", $sql);
    // `information_schema` DB로의 접근을 허락하지 않습니다.
    $sql = preg_replace("#^select.*from.*where.*`?information_schema`?.*#i", "select 1", $sql);

    if(function_exists('mysqli_query') && G5_MYSQLI_USE) {
        if ($error) {
            $result = @mysqli_query($link, $sql) or die("<p>$sql<p>" . mysqli_errno($link) . " : " .  mysqli_error($link) . "<p>error file : {$_SERVER['SCRIPT_NAME']}");
        } else {
            $result = @mysqli_query($link, $sql);
        }
    } else {
        if ($error) {
            $result = sql_query($sql, $link) or die("<p>$sql<p>" . mysql_errno() . " : " .  mysql_error() . "<p>error file : {$_SERVER['SCRIPT_NAME']}");
        } else {
            $result = sql_query($sql, $link);
        }
    }

    return $result;
}



이렇게 수정했는데 그래도 장바구니에 담기지 않네요.
영카트4 에서 5로 업그래이드 한건데, 혹시 그래서 생기는 문제 인가요?

mysql_num_rows($result); 함수 앞 부분에 @mysql_num_rows($result);

해보세요

해당 함수의 결과값을 bool 타입으로 이용해서 그런듯하네요

function sql_num_rows($result)
{
    if(function_exists('mysqli_num_rows') && G5_MYSQLI_USE)
        return mysqli_num_rows($result);
    else
        return @mysql_num_rows($result);
}

이렇게 수정했는데 같은 에러가 나네요. 제가 잘못된곳을 수정한건가요? ;;

function sql_num_rows($result)
{
    if(function_exists('mysqli_num_rows') && G5_MYSQLI_USE)
        return @mysqli_num_rows($result);
    else
        return mysql_num_rows($result);
}



이렇게 위쪽에다가 @ 넣어보니,

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/hosting_users/to_love58/www/shop/lib/common.lib.php on line 1563

문구는 안나오는데, 장바구니에 담기지가 않네요. ㅜㅜ

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

회원로그인

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