This is my script, which is intended to show a different page depending on day of the week.

<html>
<? error_reporting(E_ALL);?>
<body>
<?
$i=$_GET['day'];

switch ($i) {
case 0:
    include("2.php");
    break;
case 1:
    include("3.php");
    break;
case 2:
     include("4.php");
    break;
case 7:
      include("5.php");
    break;
default:
    echo "page not found!!!!";
}
?>
<?php
$d=date("D");
switch ($d)
{
case "Mon":
    include("2.php");
  //echo "Today is Monday";
  break;
case "Tue":
    include("3.php");
  //echo "Today is Tuesday";
  break;
case "Wed":
    include("4.php");
  //echo "Today is Wednesday";
  break;
case "Thu":
    include("5.php");
  //echo "Today is Thursday";
  break;
case "Fri":
    include("6.php");
  //echo "Today is Friday";
  break;
case "Sat":
    include("7.php");
  //echo "Today is Saturday";
  break;
case "Sun":
    include("1.php");
  //echo "Today is Sunday";
  break;
default:
//echo "Wonder which day is this ?"; 
}
?>

When I run it, it partially works, but this notice appears at the top of the browser:
Notice: Undefined index: day in C:\www\vhosts\mywebsite1\dayweek.php on line 5

I would appreciate any advice anyone has on fixing this, since I always get the undefined index error, which makes the site not function properly.

Thanks

$i=$_GET['day']; will cause the notice if you call the page without this parameter. To remove the notice, do this: $i = isset($GET['day']) ? $_GET['day'] : -1;

I get this error now in my code:
Parse error: syntax error, unexpected '}', expecting T_ENDSWITCH or T_CASE or T_DEFAULT in C:\www\vhosts\mywebsite1\dayweek.php on line 25

<html>
<body>
<?
$i = isset($GET['day']) ? $_GET['day'] : -1;
 
switch ($i) {
case 0:
    include("2.php");
    break;
case 1:
    include("3.php");
    break;
case 2:
     include("4.php");
    break;
case 7:
      include("5.php");
    break;
default:
    echo "page not found!!!!";
}
?>
<?php
$d=date("D");
switch ($d): }
case "Mon":
    include("2.php");
  //echo "Today is Monday";
  break;
case "Tue":
    include("3.php");
  //echo "Today is Tuesday";
  break;
case "Wed":
    include("4.php");
  //echo "Today is Wednesday";
  break;
case "Thu":
    include("5.php");
  //echo "Today is Thursday";
  break;
case "Fri":
    include("6.php");
  //echo "Today is Friday";
  break;
case "Sat":
    include("7.php");
  //echo "Today is Saturday";
  break;
case "Sun":
    include("1.php");
  //echo "Today is Sunday";
  break;
default:
//echo "Wonder which day is this ?"; 
}
?>

the switch should have '{' opening brace and not the closing brace '}' . that's why there's that syntax error.

Now I'm getting this error message:

Parse error: syntax error, unexpected $end in C:\www\vhosts\mywebsite1\dayweek.php on line 58

My code now:

<html>
<body>
<html>
<body>
<?
$i = isset($GET['day']) ? $_GET['day'] : -1;
 
switch ($i) {
case 0:
    include("2.php");
    break;
case 1:
    include("3.php");
    break;
case 2:
     include("4.php");
    break;
case 7:
      include("5.php");
    break;
default:
    echo "page not found!!!!";
}
?>
<?php
$d=date("D");
switch ($d) {
case "Mon":
    include("2.php");
  //echo "Today is Monday";
  break;
case "Tue":
    include("3.php");
  //echo "Today is Tuesday";
  break;
case "Wed":
    include("4.php");
  //echo "Today is Wednesday";
  break;
case "Thu":
    include("5.php");
  //echo "Today is Thursday";
  break;
case "Fri":
    include("6.php");
  //echo "Today is Friday";
  break;
case "Sat":
    include("7.php");
  //echo "Today is Saturday";
  break;
case "Sun":
    include("1.php");
  //echo "Today is Sunday";
  break;
default:
//echo "Wonder which day is this ?"; }
?>

the closing brace in line 57 is commented out, put it on the next line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.