drnl10253 2019-07-08 17:48
浏览 93
已采纳

404问题去年的时候 - php日历

I'm building a classic calendar for my website. But I have a big issue: a 404 error page when I navigate to the next year of my calendar. I've no idea to resolve that problem...

function draw_calendar($month,$year){
/*Some code for displaying calendar*/


$month = (int)  (isset($_GET['month']) ? $_GET['month'] : date('m'));
$year = (int)  (isset($_GET['year']) ? $_GET['year'] : date('Y'));

/* select month control */
$select_month_control = '<div class="form-group col-4"><select name="month" class="form-control" id="month">';
for($x = 1; $x <= 12; $x++) {
    $select_month_control.= '<option value="'.$x.'"'.($x != $month ? '' : ' selected="selected"').'>'.ucfirst(strftime('%B',mktime(0,0,0,$x,1,$year))).'</option>';
}
$select_month_control.= '</select></div>';

/* select year control */
$year_range = 7;
$select_year_control = '<div class="form-group col-4"><select name="year" class="form-control" id="year">';
for($x = $year; $x <= $year+2; $x++) {
    $select_year_control.= '<option value="'.$x.'"'.($x != $year ? '' : ' selected="selected"').'>'.$x.'</option>';
}
$select_year_control.= '</select></div>';

/* "next month" control */
$next_month_link = '<a href="?month='.($month != 12 ? $month + 1 : 1).'&year='.($month != 12 ? $year : $year + 1).'" class="control">Suivant >></a>';

/* "previous month" control */
$previous_month_link = '<a href="?month='.($month != 1 ? $month - 1 : 12).'&year='.($month != 1 ? $year : $year - 1).'" class="control"><<  Précédent</a>';

/* bringing the controls together */
$controls = '<form method="get" class="form-row">'.$select_month_control.$select_year_control.' <div class="col-4"><input type="submit" class="btn btn-outline-primary mt-0" name="go" value="Choisir" /></div> </form>';


?>
<div class="row justify-content-between mt-5">
    <div class="col-3">
        <?php echo $previous_month_link;?>
    </div>
    <div class="col-6">
        <?php echo $controls; ?>
    </div>
    <div class="col-3 text-right">
        <?php echo $next_month_link;?>
    </div>
</div>
<?php
echo draw_calendar($month,$year);
    }
}

The error is an 404 error page with the following url : https://.../?month=1&year=2020&go=Choisir

  • 写回答

1条回答 默认 最新

  • dpfl37651 2019-07-08 18:18
    关注

    Since you're on Wordpress, it seems like you're using reserved terms for $_GET variables: https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

    Change the "year" to something like "y", and you should be good to go.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥500 服务器搭建cisco AnyConnect vpn
  • ¥15 用大厂网站防红自己网站
  • ¥15 悬赏Python-playwright部署在centos7上
  • ¥15 psoc creator软件有没有人能远程安装啊
  • ¥15 快速扫描算法求解Eikonal方程咨询
  • ¥20 我的是道格手机,重置后屏幕右上角出现红色字的未写入tee key 和未写入google key请问怎么去掉啊
  • ¥15 校内二手商品转让网站
  • ¥20 高德地图聚合图层MarkerCluster聚合多个点,但是ClusterData只有其中部分数据,原因应该是有经纬度重合的地方点,现在我想让ClusterData显示所有点的信息,如何实现?
  • ¥100 求Web版SPC控制图程序包调式
  • ¥20 指导如何跑通以下两个Github代码