php8 로 업그레이드후 발생하는 오류 문의합니다

php8 로 업그레이드후 발생하는 오류 문의합니다

QA

php8 로 업그레이드후 발생하는 오류 문의합니다

본문

7.4에서 8.0 으로 올린후 두가지 에러가 발생하고 있습니다

 


/**
     * 외부 이미지 로컬에 저장하기
     */
    public function save_url_image($url, $local_image) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
        $rawdata = curl_exec($ch);
        curl_close ($ch);
        if (file_exists($local_image)){
            unlink($local_image);
        }
        $fp = fopen($local_image,'x');
        fwrite($fp, $rawdata);
        fclose($fp);
    }

PHP Fatal error:  Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given
Stack trace:
#0 /home/www/eyoom/class/bbs.class.php(1087): fwrite()
#1 /home/www/eyoom/class/bbs.class.php(1049): bbs->save_url_image()
 

 


// 결과값에서 한행 연관배열(이름으로)로 얻는다.
function sql_fetch_array($result)
{
    if( ! $result) return array();
    if(function_exists('mysqli_fetch_assoc') && G5_MYSQLI_USE)
        try {
            $row = @mysqli_fetch_assoc($result);
        } catch (Exception $e) {
            $row = null;
        }
    else
        $row = _fetch_assoc($result);
    return $row;
}

PHP Fatal error:  Uncaught TypeError: mysqli_fetch_assoc(): Argument #1 ($result) must be of type mysqli_result, array given in /home/www/lib/common.lib.php:1825
Stack trace:
#0 /home/www/lib/common.lib.php(1825): mysqli_fetch_assoc()
#1 /home/www/bbs/search.php(211): sql_fetch_array()
 

 

위 두가지 오류를 잡는 방법좀 알려주시면 고맙겠습니다

 

 

이 질문에 댓글 쓰기 :

답변 3

다음을 참고하셔서 수정을 해보시는건 어떨까 합니다.

1번째 오류


public function save_url_image($url, $local_image) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
    $rawdata = curl_exec($ch);
    curl_close ($ch);
    if (file_exists($local_image)){
        unlink($local_image);
    }
    $fp = fopen($local_image,'w'); // 'x' 대신 'w' 모드로 변경
    fwrite($fp, $rawdata);
    fclose($fp);
}

 

2번째 오류


// 결과값에서 한행 연관배열(이름으로)로 얻는다.
function sql_fetch_array($result)
{
    if( ! $result) return array();
    if(function_exists('mysqli_fetch_assoc') && G5_MYSQLI_USE) {
        try {
            $row = mysqli_fetch_assoc($result); // mysqli_query로 실행된 결과를 받음
        } catch (Exception $e) {
            $row = null;
        }
    }
    else
        $row = mysql_fetch_assoc($result);
    return $row;
}
save_url_image 이 함수를 실행하는곳의 코드도 함께 올려보세요. 

2번 질문도 마찬가지 입니다.

 

 

함수에 인자로 들어가는 데이터가 잘못된 겁니다.

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

회원로그인

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