테스트 사이트 - 개발 중인 베타 버전입니다

별점평가. 채택완료

천년만년 3년 전 조회 2,535

 

테마스킨 사용하니까 아래같은 오류가 생깁니다. 

 

24번째줄 

$write = sql_fetch($sql); 

삭제하니까 없는 게시글이라 뜹니다 

 

어디가 문제인지 조언 부탁드립니다.

 

 

 

</strong></p>

<p><strong><? 

// 기본 인클루드 

$g5_path = "../../../../../.."; // 테마 사용시 아래것 주석처리하고 요것사용

$g5_path = "../../../.."; 

//include_once("$g5_path/common.php"); </strong></p>

<p><strong>// 변수 처리 

$gr_id = $_POST[gr_id]; 

$bo_table = $_POST[bo_table]; 

$wr_id = $_POST[wr_id]; 

$star = $_POST[star];

$page = $_GET['page'];

if($member[mb_id]) $mb_id = $member[mb_id]; 

else $mb_id = $_SERVER[REMOTE_ADDR]; </strong></p>

<p><strong>// 필요한 값이 넘어왔는지 

if(!$_POST[gr_id]) die("그룹 값이 없음"); 

if(!$_POST[bo_table]) die("게시판 값이 없음"); 

if(!$_POST[wr_id]) die("글 번호가 없음"); 

if(!$_POST[star]) die("별점이 넘어오지 않음"); </strong></p>

<p><strong>// 글 내용 가져오기 

$sql = "select mb_id, wr_ip from `g5_write_$bo_table` where wr_id='$wr_id'"; 

$write = sql_fetch($sql); </strong></p>

<p><strong>// 없는 글이면 

if(!$write) die("없는 글이거나 삭제된 글입니다."); </strong></p>

<p><strong>// 내 글이면 

$s_name = "자신의 글은 추천할 수 없습니다."; 

if($write[mb_id]==$mb_id || $write[wr_ip]==$mb_id) die($s_name); 

//if($write[mb_id]==$mb_id || $write[wr_ip]==$mb_id) die("자신의 글은 추천할 수 없습니다."); </strong></p>

<p><strong>// 기존 별점 가져오기 

$sql = "select * from m3rating where bo_table='$bo_table' AND wr_id='$wr_id'"; 

$rating = sql_fetch($sql); </strong></p>

<p><strong>// 기존 별점 있으면 

if($rating) { 

// 이미 참가한 경우 

$s_name_alert = "이미 점수를 주셨습니다"; 

if(strpos(",".$rating[star_list].",", ",".$mb_id.",")!==false) die($s_name_alert);

 // 참가하지 않은 경우 별점을 추가한다. 

$star_average = (array_sum(explode(",",$rating[star_data]))+$star)/(sizeof(explode(",",$rating[star_data]))+1);

 $sql = "update m3rating set bo_table='$bo_table', wr_id='$wr_id', star_average='$star_average', star_data=CONCAT(star_data, ',$star'), star_list=CONCAT(star_list, ',$mb_id') where gr_id='$gr_id' AND bo_table='$bo_table' AND wr_id='$wr_id'";

 } 

// 기존 별점이 없으면 

else { 

$sql = "insert into m3rating set gr_id='$gr_id', bo_table='$bo_table', wr_id='$wr_id', star_average='$star', star_data='$star', star_list='$mb_id'";

 } </strong></p>

<p><strong>// 실행하기 

sql_query($sql); </strong></p>

<p><strong>// 완료

$s_name_end = "{$star}점이 반영되었습니다";

die($s_name_end); 

?> </strong></p>

<p><strong>
 

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

답변 1개

채택된 답변
+20 포인트
3년 전

sql_fetch는 그누보드내에서 사용하고 있고 정의하고 있는 함수입니다

따라서, common.php를  include하셔야 사용할 수 있습니다

include 주석 처리 한 부분을 해제해주세요

그리고 

해당 쿼리를 이용하여

 

if(!$write) die("없는 글이거나 삭제된 글입니다.");

로 글이 있는지 없는지 판단하고 있기 때문에, 해당 부분을 그에 맞게 수정하거나 하셔야 합니다

 

어떤 의도로 해당 부분을 지우고 결과를 원하는지 알기 어렵기 떄문에 그 이상 답하긴 어렵네요

로그인 후 평가할 수 있습니다

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

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

로그인