모바일에서 장바구니 담기 에러 채택완료
http://www.butterfly-korea.co.kr/shop/shop/index.php?device=mobile">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
답변 2개
위 오류는 mysql_query 결과를 mysqli_num_rows 함수에 넘겨줄 때 발생합니다.
코드 상에서 $result = mysql_query($sql); 와 유사한 코드가 있는지 확인해 보시기 바랍니다.
또는 쿼리문에 오류가 있어 결과값이 false 등일 때도 발생할 수 있습니다.
이 때는 sql_query($sql, true); 와 같이 수정하여 쿼리 오류를 확인할 수 있습니다.
답변에 대한 댓글 4개
$result = @mysql_query
이걸
$result = sql_query
이걸로 바꿔보세요.
편리님 답변대로 mysql_query()의 결과를 mysqli_num_rows()로 넘겨줘서 그런거니 mysqli_query()가 동작하도록 sql_query()를 사용하시면 됩니다.
// 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로 업그래이드 한건데, 혹시 그래서 생기는 문제 인가요?
sql_num_rows 함수를 호출하는 cart.php 파일 등에서 코드를 확인해 보셔야 합니다.
댓글을 작성하려면 로그인이 필요합니다.
<br />
해보세요<br />
<br />
해당 함수의 결과값을 bool 타입으로 이용해서 그런듯하네요
답변에 대한 댓글 2개
{
if(function_exists('mysqli_num_rows') && G5_MYSQLI_USE)
return mysqli_num_rows($result);
else
return @mysql_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
문구는 안나오는데, 장바구니에 담기지가 않네요. ㅜㅜ
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
이건 없구요. 유사한걸로
$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;
}
이런게 있어요.
이곳 문제 인가요?