Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
404下一年的问题-php日历_Php_Wordpress_Calendar - Fatal编程技术网

404下一年的问题-php日历

404下一年的问题-php日历,php,wordpress,calendar,Php,Wordpress,Calendar,我正在为我的网站创建一个经典日历。但我有一个大问题:当我导航到日历的下一年时,会出现404错误页面。我不知道如何解决这个问题 function draw_calendar($month,$year){ /*Some code for displaying calendar*/ $month = (int) (isset($_GET['month']) ? $_GET['month'] : date('m')); $year = (int) (isset($_GET['year']) ?

我正在为我的网站创建一个经典日历。但我有一个大问题:当我导航到日历的下一年时,会出现404错误页面。我不知道如何解决这个问题

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);
    }
}
错误是一个404错误页面,其url如下:

由于您使用的是Wordpress,因此您似乎在使用$\u GET变量的保留术语:


将年份更改为y,您就可以开始了。

帮助我们重现该问题。请提供格式正确的工作代码以及重现问题所需的步骤。目前,靠近末尾的大括号有问题。当您从下拉列表中选择并提交表单时是否存在问题?或者是当你点击其中一个导航链接的时候?我已经测试了你的代码,它似乎工作得很好。您是否正在使用CMS框架?更重要的是,如果您将?month=1&year=2020&go=Choisir-从您看到404的页面中删除,您是否位于提交url的同一页面上?或者你不知何故被重定向到了另一个子目录?谢谢你的帮助@帕特里克:这个问题在我提交表单和导航ilnks时都会出现。404错误在我的经验中通常不是代码问题。代码问题通常是5xx错误。404通常就是它所说的:你有一个链接去了一个它不应该去的地方。正如其他人所建议的,这可能是一个CMS的问题做一些时髦的URL重写的东西。真棒。这是“年”这个词。非常感谢。