I am getting the following php notice : Notice: Undefined variable: NextCourse in C:\Program Files (x86)\EasyPHP-5.3.3\www\exam\createMap 1.php on line 10
Notice: Undefined offset: 0 in C:\Program Files (x86)\EasyPHP-5.3.3\www\exam\createMap 1.php on line 14
Notice: Undefined offset: -1 in C:\Program Files (x86)\EasyPHP-5.3.3\www\exam\createMap 1.php on line 15
Notice: Undefined offset: 1 in C:\Program Files (x86)\EasyPHP-5.3.3\www\exam\createMap 1.php on line 16
Notice: Undefined offset: 0 in C:\Program Files (x86)\EasyPHP-5.3.3\www\exam\createMap 1.php on line 17
Notice: Undefined offset: 0 in C:\Program Files (x86)\EasyPHP-5.3.3\www\exam\createMap 1.php on line 18
Notice: Undefined variable: NextCourse in C:\Program Files (x86)\EasyPHP-5.3.3\www\exam\createMap 1.php on line 10
this is the piece of code related for the notice:
require_once("MySQLConnection.php");
function get_next_course ($CurrentCourse){
$arr_all_courses=array('CS11','CS112','CS113');
$arrlength = count($arr_all_courses);
for($i = 0; $i < $arrlength; $i++) {
if ($CurrentCourse==$arr_all_courses[$i])
$NextCourse=$arr_all_courses[$i+1];
}
return $NextCourse;
}
function CanSeat($i,$j,$CourseCode) {
$array_temp=array();
$curr_element=$array_temp[$i][$j];
$above_element=$array_temp[$i-1][$j];
$below_element=$array_temp[$i+1][$j];
$right_element=$array_temp[$i][$j+1];
$left_element=$array_temp[$i][$j-1];
if ($curr_element==$above_element || $curr_element==$below_element || $curr_element==$right_element || $curr_element==$left_element)
{$next_element=get_next_course($CourseCode);
CanSeat($i,$j,$next_element);
} else return true ;
}
and this is the loop calling the above function
for ($i=0;$i<$nbCol;$i++)
{
for($j=0;$j<$nbRow;$j++)
{
$CurrentCourse=$arr_all_courses[$h];
if (CanSeat($i,$j,$CurrentCourse))
$arr_map[i][j]=$CurrentCourse;
$h++;
if($h==3)
$h=0;
}
}
Any help ?!