바다사랑님의 최신글에서 공지먼저 일반글 다음에 출력에 관한 에러입니다. 정보
바다사랑님의 최신글에서 공지먼저 일반글 다음에 출력에 관한 에러입니다.본문
오류가 나는곳의 주소를 알려주시면 더 빠르고 정확하게 답변 받을 수 있습니다.
오류 주소 :
바다사랑님의 팁을 보고
lib/latest.lib.php
의 내용을 아래와 같이 수정을 해봤습니다.
공지가 먼저 출력되기는 하는데, 공지사항이 하나도 없을 경우엔 아래와 같은 에러가 발생이 됩니다.
소스의 어떤 부분을 손을 봐야 하는지 모르겠습니다.
그리고 또 하나의 문제점이 최신글에서 글을 10개 출력을 할 때 게시판 글이 10개보다 적을 경우 최신글에 리스트가 두번씩 출력이 됩니다.
select * from g4_write_1_6_2 where wr_is_comment = 0 order by wr_num limit 0, -539
1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-539' at line 1
error file : /sge/index.php
-- 바다사랑님의 최신글에서 공지먼저 출력
<?
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$arr_notice = split("\n", trim($board[bo_notice]));
$sql_notice = "";
for($i=0;$i<count($arr_notice);$i++){
if($i != 0){
$sql_notice .= " or ";
}
$arr_notice[$i] = trim($arr_notice[$i]);
if (strlen($arr_notice[$i]) > 0) $sql_notice .= "wr_id=$arr_notice[$i]";
}
if (strlen($sql_notice) > 0) $sql_notice = " and ( " . $sql_notice . ") ";
//$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
// 위의 코드 보다 속도가 빠름
$sql = " select * from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
$count = " select count(*) as cnt from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $rows ";
$cnt = sql_fetch($count);
$total = $rows - $cnt[cnt];
$sql_notice = "";
for($i=0;$i<count($arr_notice);$i++){
if($i != 0){
$sql_notice .= " and ";
}
$arr_notice[$i] = trim($arr_notice[$i]);
if (strlen($arr_notice[$i]) > 0) $sql_notice .= "wr_id != $arr_notice[$i]";
}
if (strlen($sql_notice) > 0) $sql_notice = " and ( " . $sql_notice . ") ";
$sql_common = " select * from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $total ";
$result = sql_query($sql_common);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[($i+$cnt[cnt])] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
오류 주소 :
바다사랑님의 팁을 보고
lib/latest.lib.php
의 내용을 아래와 같이 수정을 해봤습니다.
공지가 먼저 출력되기는 하는데, 공지사항이 하나도 없을 경우엔 아래와 같은 에러가 발생이 됩니다.
소스의 어떤 부분을 손을 봐야 하는지 모르겠습니다.
그리고 또 하나의 문제점이 최신글에서 글을 10개 출력을 할 때 게시판 글이 10개보다 적을 경우 최신글에 리스트가 두번씩 출력이 됩니다.
select * from g4_write_1_6_2 where wr_is_comment = 0 order by wr_num limit 0, -539
1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-539' at line 1
error file : /sge/index.php
-- 바다사랑님의 최신글에서 공지먼저 출력
<?
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$arr_notice = split("\n", trim($board[bo_notice]));
$sql_notice = "";
for($i=0;$i<count($arr_notice);$i++){
if($i != 0){
$sql_notice .= " or ";
}
$arr_notice[$i] = trim($arr_notice[$i]);
if (strlen($arr_notice[$i]) > 0) $sql_notice .= "wr_id=$arr_notice[$i]";
}
if (strlen($sql_notice) > 0) $sql_notice = " and ( " . $sql_notice . ") ";
//$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
// 위의 코드 보다 속도가 빠름
$sql = " select * from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
$count = " select count(*) as cnt from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $rows ";
$cnt = sql_fetch($count);
$total = $rows - $cnt[cnt];
$sql_notice = "";
for($i=0;$i<count($arr_notice);$i++){
if($i != 0){
$sql_notice .= " and ";
}
$arr_notice[$i] = trim($arr_notice[$i]);
if (strlen($arr_notice[$i]) > 0) $sql_notice .= "wr_id != $arr_notice[$i]";
}
if (strlen($sql_notice) > 0) $sql_notice = " and ( " . $sql_notice . ") ";
$sql_common = " select * from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $total ";
$result = sql_query($sql_common);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[($i+$cnt[cnt])] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
댓글 전체