채택완료

Illegal string offset 뜹니다.

php5.6에서 잘 되던 것이

php7.4에서 저렇게 뜹니다.

 


Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37

Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48

 

소스는 아래와 같습니다.

Copy
<?php
    # 총 4군데 변경입니다.
    # common.php 파일 위치 절대 경로 세팅
    include_once ("../common.php"); # 꼭 변경하세요.

    # 기본 설정
    $wwwPath = "../"; # 꼭 변경하세요.
    $wwwURL = "http://domail.com"; # 꼭 변경하세요.
    
    # 게시판 리스트
    $sql = " SELECT * FROM {$g5['board_table']} WHERE bo_read_level = 1";
    $query = sql_query($sql);
    
    while ($row = sql_fetch_array($query)) {
        $board[] = $row;
    }
    
    # 파일 작성 시작
    $sitemap = fopen($wwwPath.'/sitemap/sitemap.xml', 'w') or die('file not found'); # 사이트맵 생성 경로 변경
        fwrite($sitemap, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        fwrite($sitemap, '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
    
        $boardLink = "";
        $contentLink = "";
        foreach ($board as $key => $val) :
            # 마지막 게시물 시간
            $sql = " SELECT * FROM {$g5['write_prefix']}{$val['bo_table']} WHERE wr_id = wr_parent AND wr_is_comment = 0 ORDER BY wr_datetime DESC LIMIT 0, 1";
            $query = sql_fetch($sql);
            
            # 마지막 게시물 생성 시간이 없으면 현재 시간으로 설정
            $query['wr_datetime'] = (empty($query['wr_datetime'])) ? date('Y-m-d\TH:i:s')."+00:00" : preg_replace("/\s/im", "T", $query['wr_datetime'])."+00:00";
            
            # 게시판 링크 작성
            $boardLink = "";
            $boardLink = "<url>";
                $boardLink .= "<loc>";
                    $boardLink .= G5_URL."/{$val['bo_table']}";
                $boardLink .= "</loc>";
                $boardLink .= "<lastmod>{$query['wr_datetime']}</lastmod>";
                $boardLink .= "<changefreq>daily</changefreq>";
                $boardLink .= "<priority>0.9</priority>";
            $boardLink .= "</url>";
            
            # 게시판 링크 작성
            fwrite($sitemap, $boardLink);
            
            # 게시판 게시물 작성
            $sql = " SELECT * FROM {$g5['write_prefix']}{$val['bo_table']} WHERE wr_id = wr_parent AND wr_is_comment = 0 ORDER BY wr_datetime DESC";
            $query = sql_query($sql);
            
            unset($row);
            while ($row = sql_fetch_array($query)) {
                $row['wr_datetime'] = (empty($row['wr_datetime'])) ? date('Y-m-d\TH:i:sp')."+00:00" : preg_replace("/\s/im", "T", $row['wr_datetime'])."+00:00";
                $contentLink = "";
                $contentLink = "<url>";
                    $contentLink .= "<loc>";
                        $contentLink .= G5_URL."/{$val['bo_table']}/{$row['wr_id']}";
                    $contentLink .= "</loc>";
                    $contentLink .= "<lastmod>".preg_replace("/\s/im", "T", $row['wr_datetime'])."</lastmod>";
                    $contentLink .= "<changefreq>weekly</changefreq>";
                    $contentLink .= "<priority>0.5</priority>";
                $contentLink .= "</url>";
                
                # 게시판 게시물 링크 작성
                fwrite($sitemap, $contentLink);
            }
        endforeach;
        
        fwrite($sitemap, '</urlset>');
    fclose($sitemap);
?>
<p>완료</p>
|

답변 2개 / 댓글 2개

채택된 답변
+20 포인트

5.6꺼를 그대로 쓰고싶으면 7.3으로 바꾸세요 

그담 버전부터들은 배열안에 값들 넣어줄때 ''으로 막아줘야지 오류배출안해요

답변에 대한 댓글 2개

이미 호스팅을 신청해 놓은 상태라서요. ㅠ.ㅠ
가능하시면 어디를 바꾸어야 알려 주시면 감사 하겠습니다.
너무 오랫만에 봐서 그런지 바보가 된거 같네요. ㅠ.ㅠ
print_r($val) 해보시고 bo_table 이 있는지 확인부터 해보셔요

7.4부터는 까다로워요 8은 더더욱 심하구요

문자열 오프셋이 잘못됐다고하네요 

 

$val['bo_table'] 이걸 디버깅해보세요 값이 재대로 나오는지

답변을 작성하려면 로그인이 필요합니다.