Re: [問題] 限定時間過後即關閉系統的程式

看板PHP作者 (yaguchi)時間18年前 (2007/08/10 10:37), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串3/4 (看更多)
※ 引述《noguchi (耶?!)》之銘言: 前刪 : $sql = "SELECT * FROM setdate Where startyear = '$startyear' AND : startmonth = '$startmonth' AND startday = '$startday' AND : starthour = '$starthour' AND closingyear = '$closingyear' : AND closingmonth = '$closingmonth' AND closingday = '$closingday' : AND closinghour = '$closinghour'"; 首先這段sql... 我不懂這一段是要取出什麼資料 首先這八個變數 $startyear $startmonth ..... 是哪邊來的? 前面也沒看到你有指定 然後所以你的資料表最少也有八格囉? : $result = mysql_query($sql, $link); : if (!$result) die("執行 SQL 命令失敗"); : if (mysql_num_rows($result) != 0) : { mysql_free_result($result); : $timestamp1 = mktime($starthour,0,0,$startmonth,$startday,$startyear); : $timestamp2 = mktime($closinghour,0,0,$closingmonth,$closingday,$closingyear); : } 然後$result也就不見了, timestamp也是直接用這八個變數產生 是在測試這八個變數跟資料庫的符不符合嗎? : mysql_close($link); : if(time()<$timestamp1) exit('尚未開放'); : else if(time()>$timestamp2) exit('期限已過'); : else {header("Location:index1.php");} : ?> 所以如果這八個變數是空值, mktime(0,0,0,0,0,0) 出來的東西 那當然任何時間的time()都比他大, 所以期限都過了 你第一步可以先看看你sql取出來的$result是什麼東西 再來看看你兩個$timestamp的值是什麼 如果是我的話會這樣做 管理者那邊產生timestamp 進資料庫 $timestamp1=mktime(xxxx); 驗證的這一端直接取timestamp來判斷就好 資料表看是要設成 var start end ----------------------------------------- timerange 118670000 118680000 或是 var value ------------------------- start_time 118670000 end_time 118680000 這樣直接去select xxx where var=xxx 大概這樣吧 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.121.125.159

08/11 23:16, , 1F
那資料型態是設成什麼呀?
08/11 23:16, 1F
文章代碼(AID): #16kyzU0V (PHP)
文章代碼(AID): #16kyzU0V (PHP)