하루에 글 1회만 작성가능하게 한것을 수정하고 싶습니다. 채택완료
숀보영
10년 전
조회 5,062
$sql = " select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and wr_datetime like '".G5_TIME_YMD."%' ";
$row = sql_fetch($sql);
if ($row[cnt] > 0 & !$is_admin) {
alert("이미 오늘 글쓰기 가능횟수 1회를\\n모두 소진 하셨습니다.");
}
이렇게 되면 글쓰기 가능횟수가 자정에 초기화가 되는데
이것을 오전 9시로 변경하고 싶습니다... 어떻게 해야 할지 도통 감이 안잡히네요.
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
10년 전
쿼리구문을 바꿔보세요.
$sql = " select * from count(*) as cnt where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp(wr_datetime) ";
로그인 후 평가할 수 있습니다
답변에 대한 댓글 11개
�
숀보영
10년 전
카츠님 그렇게 하면 sql 오류가 납니다 ㅠㅠ
�
숀보영
10년 전
select * from count(*) as cnt where mb_id = 'admin' and unix_timestamp('2015-04-21 09:00:00') < unix_timestamp(wr_datetime)
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 'select * from count(*) as cnt where mb_id = 'admin' and unix_timestamp(' at line 1
error file : /bbs/bbs/write.php
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 'select * from count(*) as cnt where mb_id = 'admin' and unix_timestamp(' at line 1
error file : /bbs/bbs/write.php
�
카츠
10년 전
ㅋ 구문오류가 있게 해놨군요;;
select count(*) as cnt from $write_table where mb_id = 'admin' and unix_timestamp('2015-04-21 09:00:00') < unix_timestamp(wr_datetime)
입니다.
select count(*) as cnt from $write_table where mb_id = 'admin' and unix_timestamp('2015-04-21 09:00:00') < unix_timestamp(wr_datetime)
입니다.
�
숀보영
10년 전
$sql = "select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp(wr_datetime)";
이렇게 적용했더니 구문오류는 뜨지않으나 적용이 되지 않습니다..
이렇게 적용했더니 구문오류는 뜨지않으나 적용이 되지 않습니다..
�
카츠
10년 전
그럼 그 게시판에 해당조건에 부합하는 레코드가 없는거죠.
결과물 mysql 상에서 바로 확인해서 보시려면..
echo $sql; 찍어서 phpmyadmin 이나 mysql console 에서 확인해보세요.
적어드린 쿼리문자체는 해당게시판에 접속한 현재날짜의 9시 이후 내가 작성한 게시물이 몇개인지를 세어보는 쿼리니까요.
결과물 mysql 상에서 바로 확인해서 보시려면..
echo $sql; 찍어서 phpmyadmin 이나 mysql console 에서 확인해보세요.
적어드린 쿼리문자체는 해당게시판에 접속한 현재날짜의 9시 이후 내가 작성한 게시물이 몇개인지를 세어보는 쿼리니까요.
�
숀보영
10년 전
select count(*) as cnt from g5_write_freeboard where mb_id = 'admin' and unix_timestamp('2015-04-22 09:00:00') < unix_timestamp(wr_datetime)
이렇게 나오네요.
wr_datetime이 최근 글 작성 시간으로 나와야 하는데
저렇게 나와요 ㅠㅠ
이렇게 나오네요.
wr_datetime이 최근 글 작성 시간으로 나와야 하는데
저렇게 나와요 ㅠㅠ
�
숀보영
10년 전
$sql = "select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp('$_wr_datetime')";
이렇게 수정하여 작성하오니
select count(*) as cnt from g5_write_freeboard where mb_id = 'admin' and unix_timestamp('2015-04-22 09:00:00') < unix_timestamp('2015-04-22 02:39:43')
이렇게 정상적으로 나오나 역시나 작동은 하지 않습ㄴ디ㅏ ㅠㅠ
이렇게 수정하여 작성하오니
select count(*) as cnt from g5_write_freeboard where mb_id = 'admin' and unix_timestamp('2015-04-22 09:00:00') < unix_timestamp('2015-04-22 02:39:43')
이렇게 정상적으로 나오나 역시나 작동은 하지 않습ㄴ디ㅏ ㅠㅠ
�
카츠
10년 전
echo 결과로 받은 아래 쿼리를 phpmyadmin 등에서 실행해 보세요. 그럼 결과값이 비었는지 갯수가 나오는지 아실거 아닌가요?
select count(*) as cnt from g5_write_freeboard where mb_id = 'admin' and unix_timestamp('2015-04-22 09:00:00') < unix_timestamp('2015-04-22 02:39:43')
전체소스를 보지않는이상 쿼리외에 어떤이상이 잇는지 까지는 제가 답변해 드릴수가 없어요.
select count(*) as cnt from g5_write_freeboard where mb_id = 'admin' and unix_timestamp('2015-04-22 09:00:00') < unix_timestamp('2015-04-22 02:39:43')
전체소스를 보지않는이상 쿼리외에 어떤이상이 잇는지 까지는 제가 답변해 드릴수가 없어요.
�
숀보영
10년 전
phpmyadmin에서 실행할 경우에
SELECT count( * ) AS cnt
FROM g5_write_freeboard
WHERE mb_id = 'admin'
AND unix_timestamp( '2015-04-22 09:00:00' ) < unix_timestamp( '2015-04-22 03:12:30' )
cnt
26
이렇게 나옵니다.
그리고 전체소스도 이것뿐 입니다.
<?
$sql = "select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp('$_wr_datetime')";
$row = sql_fetch($sql);
if ($row[cnt] > 0) {
alert("이미 오늘 인증횟수 1회를\\n모두 소진 하셨습니다.");
}
?>
저 cnt 26개는 오늘만 쓴글이 아니라
freeboard 전체에 쓴 게시물수입니다..
SELECT count( * ) AS cnt
FROM g5_write_freeboard
WHERE mb_id = 'admin'
AND unix_timestamp( '2015-04-22 09:00:00' ) < unix_timestamp( '2015-04-22 03:12:30' )
cnt
26
이렇게 나옵니다.
그리고 전체소스도 이것뿐 입니다.
<?
$sql = "select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp('$_wr_datetime')";
$row = sql_fetch($sql);
if ($row[cnt] > 0) {
alert("이미 오늘 인증횟수 1회를\\n모두 소진 하셨습니다.");
}
?>
저 cnt 26개는 오늘만 쓴글이 아니라
freeboard 전체에 쓴 게시물수입니다..
�
카츠
10년 전
admin 으로 로그인은 한상태에서 테스트하셨나요?
로그인이 안되어 있다면 쿼리가 달라집니다. mb_id='' 으로 반영되는거죠
그리고 작성된 쿼리에서
<?
$sql = "select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp('$_wr_datetime')";
$row = sql_fetch($sql);
if ($row[cnt] > 0) {
alert("이미 오늘 인증횟수 1회를\\n모두 소진 하셨습니다.");
}
?>
'$_wr_datetime' <- 이거 아닙니다. wr_datetime 필드명만 적어야 됩니다. 이렇게 했으면 결과가 당연히 맞게 안나옵니다.
그리고 자꾸 문의주시길래.. 확인해봤습니다. 이상없는 코드입니다.
로그인이 안되어 있다면 쿼리가 달라집니다. mb_id='' 으로 반영되는거죠
그리고 작성된 쿼리에서
<?
$sql = "select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp('$_wr_datetime')";
$row = sql_fetch($sql);
if ($row[cnt] > 0) {
alert("이미 오늘 인증횟수 1회를\\n모두 소진 하셨습니다.");
}
?>
'$_wr_datetime' <- 이거 아닙니다. wr_datetime 필드명만 적어야 됩니다. 이렇게 했으면 결과가 당연히 맞게 안나옵니다.
그리고 자꾸 문의주시길래.. 확인해봤습니다. 이상없는 코드입니다.
�
숀보영
10년 전
<?
$sql = "select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp(wr_datetime)";
echo $sql;
$row = sql_fetch($sql);
if ($row[cnt] > 0) {
alert("이미 오늘 인증횟수 1회를\\n모두 소진 하셨습니다.");
}
?>
이렇게 소스를 사용하였고
select count(*) as cnt from g5_write_Sean where mb_id = 'admin' and unix_timestamp('2015-04-22 09:00:00') < unix_timestamp(wr_datetime)
이것도 myphpadmin에 돌려보니
cnt 가 4개로 나왔습니다.
그러나 정상적으로 작동하진 않습니다...
$sql = "select count(*) as cnt from $write_table where mb_id = '$member[mb_id]' and unix_timestamp('".G5_TIME_YMD." 09:00:00') < unix_timestamp(wr_datetime)";
echo $sql;
$row = sql_fetch($sql);
if ($row[cnt] > 0) {
alert("이미 오늘 인증횟수 1회를\\n모두 소진 하셨습니다.");
}
?>
이렇게 소스를 사용하였고
select count(*) as cnt from g5_write_Sean where mb_id = 'admin' and unix_timestamp('2015-04-22 09:00:00') < unix_timestamp(wr_datetime)
이것도 myphpadmin에 돌려보니
cnt 가 4개로 나왔습니다.
그러나 정상적으로 작동하진 않습니다...
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인