我正在将我的网站从我们的旧服务器(MS Server 2003,PHP 5.1,IIS 6)移动到新服务器(MS Server 2008 R2,PHP 5.3,IIS 7.5),以下代码给了我一个"PHP通知:未定义的变量:年份......"在我的新服务器上,但它在旧服务器上工作正常。 我认为这是PHP,但有人可以对此有所了解吗? $year变量在这里有问题。 每次我运行表单时,它都会返回"对不起,访问不当"。 提前谢谢你。
<?php
if ( $year=='2012') || $year=='2013' || $year=='2014') <~~~~~ Error Here
{
$nextyr=$year+1;
$prevyr=$year-1;
$prevyr = substr($prevyr, -2,2);
$lookupyr = substr($year, -2);
$nextyr = substr($nextyr, -2);
if ( $sess == 'SP' ){ $EXyear=$prevyr.$lookupyr; }
else if ( $sess == 'SU' ){ $EXyear=$prevyr.$lookupyr; }
else { $EXyear=$lookupyr.$nextyr; }
}
else { $EXyear=$year; } <~~~~~~ Error Here
if (!isset($FacID))
{
if (!isset($crs) || !isset($sess) || !isset($year))
exit("<h1 align='center'>Sorry, Improper Access</h1>");
看起来你缺少一个参数
if ( $year=='2012') || $year=='2013' || $year=='2014')
应该是
if ( $year=='2012' || $year=='2013' || $year=='2014')
或者也许(但我不明白为什么)
if (( $year=='2012') || $year=='2013' || $year=='2014')