sql 코드 출력 오류
본문
서버 이전하면서 php 버전이 틀려서 오류가 발생하는데 항목을 입력해서 추가하면 리스트에 출력이 되어야 하는데 추가가 안됩니다. 해결 방법 알고 계시면 답변주시면 감사하겠습니다!
---입력 코드---
<?
$SQL = "SELECT m_no,m_name,m_sex FROM g5_listm order by m_no asc";
$rs = sql_query($SQL);
while($row = sql_fetch_array($rs))
{
?>
<option value='<?=$row['m_no']?>' ><?=$row['m_name']?>(<?=$row['m_sex']=='m'?'남':'여'?>)</option>
<?
}
?>
---목록 노출 코드---
<? $SQL = "select * from list_view where d_date between '".$_SESSION['sdate']."' and '".$_SESSION['edate']."' and m_name like '%".$search."%' "; $SQL .= " and d_memo like '%".$memo."%' "; if($type != '') { $SQL .= " and d_type = '".$type."' "; } $SQL .= " and d_mno != '' "; $SQL .= " order by d_date asc"; $rs = sql_query($SQL); while($row = sql_fetch_array($rs)) { ?>
답변 3
short_open_tag = Off 환경이면 아래처럼 PHP 시작 태그를 변경해주세요.
<? → <?php
댓글에 첨부한 전체 코드에서 5곳이군요.
* 참고로 <?= 표현은 PHP 5.4 버전 이상에서 설정과 상관없이 항상 사용 가능하니 괜찮습니다.
(무조건 <?php echo ... 형태가 좋은 것이 아닙니다.)
에러 메세지를 보여주세요
에러 메시지는 없고 전체 코드 올려드립니다.
<?php
$sub_menu = "400200";
include_once('./_common.php');
auth_check($auth[$sub_menu], 'r');
$sql_common = " from {$g5['board_table']} a ";
$sql_search = " where (1) ";
if ($is_admin != "super") {
$sql_common .= " , {$g5['group_table']} b ";
$sql_search .= " and (a.gr_id = b.gr_id and b.gr_admin = '{$member['mb_id']}') ";
}
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case "bo_table" :
$sql_search .= " ($sfl like '$stx%') ";
break;
case "a.gr_id" :
$sql_search .= " ($sfl = '$stx') ";
break;
default :
$sql_search .= " ($sfl like '%$stx%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "a.gr_id, a.bo_table";
$sod = "asc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt {$sql_common} {$sql_search} {$sql_order} ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$rows = $config['cf_page_rows'];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select * {$sql_common} {$sql_search} {$sql_order} limit {$from_record}, {$rows} ";
$result = sql_query($sql);
$listall = '<a href="'.$_SERVER['SCRIPT_NAME'].'" class="ov_listall">전체목록</a>';
$g5['title'] = '당직/휴진관리';
include_once('./admin.head.php');
$colspan = 15;
//현재 월 처음~끝 값 구하기
if(!isset($_GET['sdate']))
$_SESSION['sdate'] = date("Y-m",time())."-01";
else
$_SESSION['sdate'] = $_GET['sdate'];
if(!isset($_GET['edate']))
$_SESSION['edate'] = date("Y-m",time())."-".date("t",time());
else
$_SESSION['edate'] = $_GET['edate'];
//이전 월 값 구하기
$prev_sdate = date("Y-m", strtotime($_SESSION['sdate']." -1 month"))."-01";
$prev_edate = date("Y-m", strtotime($_SESSION['sdate']." -1 month"))."-".date("t",strtotime($_SESSION['sdate']." -1 month"));
//다음 월 값 구하기
$next_sdate = date("Y-m", strtotime($_SESSION['sdate']." +1 month"))."-01";
$next_edate = date("Y-m", strtotime($_SESSION['sdate']." +1 month"))."-".date("t",strtotime($_SESSION['sdate']." +1 month"));
?>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
<script>
$(document).ready(function(){
$.datepicker.regional['ko'] = {
closeText: '닫기',
prevText: '이전달',
nextText: '다음달',
currentText: '선택일',
monthNames: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)',
'7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'],
monthNamesShort: ['1월','2월','3월','4월','5월','6월',
'7월','8월','9월','10월','11월','12월'],
dayNames: ['일','월','화','수','목','금','토'],
dayNamesShort: ['일','월','화','수','목','금','토'],
dayNamesMin: ['일','월','화','수','목','금','토'],
weekHeader: 'Wk',
dateFormat: 'yy-mm-dd',
firstDay: 0,
isRTL: false,
showMonthAfterYear: true,
yearSuffix: '',
showOn: 'button',
duration:200,
showAnim:'show',
buttonImage: "/inc/calendar.png",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: 'c-99:c+99',
};
$.datepicker.setDefaults($.datepicker.regional['ko']);
$('#s_date').datepicker();
$('#e_date').datepicker();
$('#d_date').datepicker();
});
</script>
<br><br>
<div style="padding-bottom:15px;">
1. 검색 선택
</div>
<div class="tbl_head01 tbl_wrap">
<!-- 날짜 및 이름 검색 폼 -->
<form action="<?=$_SERVER['PHP_SELF']?>" method="GET" name="frm1">
<a class="btn" href="<?=$_SERVER['PHP_SELF']?>?sdate=<?=$prev_sdate?>&edate=<?=$prev_edate?>&<?=$_GET['site_gubun']=='1'?'site_gubun=1':''?>" style="padding-right:10px;"><img src="/inc/lico.png" /></a>
<input type="text" name="sdate" id="s_date" placeholder="시작일" style="width:80px;margin-right:0px;" value="<?=$_SESSION['sdate']?>" class="frm_input"> ~
<input type="text" name="edate" id="e_date" placeholder="종료일" style="width:80px;margin-right:0px;" value="<?=$_SESSION['edate']?>" class="frm_input">
<a class="btn" href="<?=$_SERVER['PHP_SELF']?>?sdate=<?=$next_sdate?>&edate=<?=$next_edate?>&<?=$_GET['site_gubun']=='1'?'site_gubun=1':''?>" style="padding-left:10px;padding-right:20px;"><img src="/inc/rico.png" /></a>
<input name="search" type="text" style="margin:0px;" placeholder="이름" value="<?=$search?>" class="frm_input">
<select name="type" style="height:24px;">
<option value="">당직/휴진 전체보기</option>
<option value="o">당직</option>
<option value="q">휴진</option>
<option value="p">오전</option>
</select>
<input name="memo" type="text" style="margin:0px;" placeholder="메모" value="<?=$memo?>" class="frm_input">
<input type="submit" value="검색" style="color:#000;background:#eeeeee;border:1px solid silver;width:100px;height:24px;">
</form>
<!--
<br><br>
검색 값<br>
시작일 <?=$_SESSION['sdate']?> <br>
종료일 <?=$_SESSION['edate']?> <br>
검색어 <?=$_GET['search']?><br>
-->
<br><br>
</div>
<div style="padding-bottom:15px;">
2. 당직/휴진 입력하기
</div>
<div class="tbl_head01 tbl_wrap">
<form name="dinput" action="list_d_action.php?mode=add" method="POST" enctype="multipart/form-data">
<table>
<thead>
<tr>
<th width="200px;">날짜</th>
<th width="200px;">담당자 이름</th>
<th width="100px;">당직/휴진/오전</th>
<th>메모</th>
<th width="100px;"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"><input type="text" name="d_date" id="d_date" style="width:80%;" value="<?=date("Y-m-d")?>" class="required frm_input"/></td>
<td style="text-align:center;">
<select name="d_mno" style="width:90%;height:24px;">
<?
$SQL = "SELECT m_no,m_name,m_sex FROM g5_listm order by m_no asc";
$rs = sql_query($SQL);
while($row = sql_fetch_array($rs))
{
?>
<option value='<?=$row['m_no']?>' ><?=$row['m_name']?>(<?=$row['m_sex']=='m'?'남':'여'?>)</option>
<?
}
?>
</select>
</td>
<td style="text-align:center;">
<select name="d_type" style="width:90%;height:24px;">
<option value="o">당직</option>
<option value="q">휴진</option>
<option value="p">오전</option>
</select>
</td>
<td style="text-align:center;"><input type="text" name="d_memo" value="" style="width:97%;" class="frm_input"/></td>
<td><input type="submit" value="추가하기" style="color:#000;background:#eeeeee;border:1px solid silver;width:100%;height:24px;"></td>
</tr>
</tbody>
</table>
</form>
</div>
<br><br>
<div style="padding-bottom:15px;">
3. 당직/휴진 목록 <a href="/inc/sub06_8.php" target="_blank" style="color:orange"> + 달력에서보기</a>
</div>
<div class="tbl_head01 tbl_wrap">
<table>
<thead>
<tr>
<th width="200px;">날짜</th>
<th width="200px;">담당자 이름</th>
<th width="100px;">당직/휴진/오전</th>
<th>메모</th>
<th width="100px;"></th>
</tr>
</thead>
<tbody>
<?
$SQL = "select * from list_view where d_date between '".$_SESSION['sdate']."' and '".$_SESSION['edate']."' and m_name like '%".$search."%' ";
$SQL .= " and d_memo like '%".$memo."%' ";
if($type != '')
{
$SQL .= " and d_type = '".$type."' ";
}
$SQL .= " and d_mno != '' ";
$SQL .= " order by d_date asc";
$rs = sql_query($SQL);
while($row = sql_fetch_array($rs))
{
?>
<tr>
<td style="text-align:center;"><?=$row['d_date']?></td>
<td style="text-align:center;"><?=$row['m_name']?></td>
<td style="text-align:center;">
<?
if($row['d_type']=='o')
{
echo "<span style='background:#e45e5b;color:#fff;-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;'>당직</span>";
}
else if($row['d_type']=='q')
{
echo "<span style='background:#a1abc9;color:#fff;-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;'>휴진</span>";
}
else if($row['d_type']=='p')
{
echo "<span style='background:#00a651;color:#fff;-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;'>오전</span>";
}
else
{
echo "입력오류";
}
?>
</td>
<td style="text-align:left;"> <?=$row['d_memo']?></td>
<td>
<form name="mdel_<?=$row['m_no']?>" action="list_d_action.php?mode=del" method="POST" onsubmit="return fboardlist_submit(this);" enctype="multipart/form-data">
<input type="hidden" name="d_no" value="<?=$row['d_no']?>" />
<input type="submit" value="삭제" style="color:#000;background:#eeeeee;border:1px solid silver;width:100%;height:24px;" onclick="document.pressed=this.value" />
</form>
</td>
</tr>
<?
}
?>
</tbody>
</table>
</div>
<script>
function fboardlist_submit(f)
{
if(document.pressed == "삭제") {
if(!confirm("선택한 자료를 정말 삭제하시겠습니까?")) {
return false;
}
}
return true;
}
</script>
<?php
include_once('./admin.tail.php');
?>