0

Hi all, I having this error "Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\FYP\assign_venueTest.php on line 104" in my code. I cant find where does my code went wrong. Need you guys to help me out.

<?php
	$class_id = $_GET['id'];
	$HOST = 'localhost';
	$USERNAME = 'root';
	$PASSWORD = '';
	$DB = 'sjas';
	$link = mysqli_connect($HOST,$USERNAME,$PASSWORD,$DB);
	
	//get class
	$sql1 = "SELECT * FROM class,course WHERE idClass = $class_id and Course_idCourse = idCourse";
	$result1 = mysqli_query($link,$sql1) or die(mysqli_error($link));
	$row1 = mysqli_fetch_array($result1);
	
	//get students
	$sql2 = "SELECT * FROM member m,attendance a WHERE Class_idClass = $class_id and Member_idMember = idMember group by idMember";
	$result2 = mysqli_query($link,$sql2) or die(mysqli_error($link));
	$no_student = mysqli_num_rows($result2);
	$student_name = mysqli_fetch_array($result2);
	
	//Get information of assigning class
	$assigning = "Select Class_idCLass,Venue_idVenue,day01,day02,day03,day04,day05,day06,day07,day08,day09,day10,day11,day12 from attendance, class where Venue_idVenue IS NULL and Class_idClass = $class_id group by Class_idClass";
	$assigning_result = mysqli_query($link,$assigning) or die(mysqli_error($link));
	$assigning_no = mysqli_num_rows($assigning_result);
	$assigning_venue = mysqli_fetch_array($assigning_result);
	
	//For Assigning Day duration
	$assigning_day = "Select Class_idCLass,Venue_idVenue,idVenue, idTime_Slot from attendance, class, time_slot, venue where Venue_idVenue IS NULL and Class_idClass = $class_id and idTime_Slot = 1 group by Class_idClass";
	$assigning_day_result = mysqli_query($link,$assigning_day) or die(mysqli_error($link));
	$assigning_no = mysqli_num_rows($assigning_day_result);
	$assigning_venue = mysqli_fetch_array($assigning__day_result);
	
	//For Assigning Night duration
	$assigning_night = "Select Class_idCLass,Venue_idVenue,idVenue, idTime_Slot from attendance, class, time_slot, venue where Venue_idVenue IS NULL and Class_idClass = $class_id and idTime_Slot = 2 group by Class_idClass";
	$assigning_night_result = mysqli_query($link,$assigning_night) or die(mysqli_error($link));
	$assigning_no = mysqli_num_rows($assigning_night_result);
	$assigning_venue = mysqli_fetch_array($assigning_night_result);
	
	//Get Assigned Venue's information
	$assigned = "Select Class_idCLass,Venue_idVenue,day01,day02,day03,day04,day05,day06,day07,day08,day09,day10,day11,day12 from attendance a,class c where a.Class_idClass is not Null and a.Venue_idVenue is not Null Group by Class_idClass";
	$assigned_result = mysqli_query($link,$assigned) or die(mysqli_error($link));
	$assigned_venue = mysqli_fetch_array($assigned_result);
	$assigned_venue_no = mysqli_num_rows($assigned_result);
	
	//For Assigned Day duration
	$assigned_day = "Select Class_idClass,Venue_idVenue,idTime_Slot from attendance, class, time_slot WHERE Class_idClass = idClass and idTime_Slot = 1 and Time_Slot_idTime_Slot = idTime_Slot 
		 and Venue_idVenue IS NOT Null GROUP BY Class_idClass";
	$assigned_day_result = mysqli_query($link,$assigned_day) or die(mysqli_error($link));
	$assigned_day_array = mysqli_fetch_array($assigned_day_result);
	$assigned_day_row = mysqli_num_rows($assigned_day_result);
	
	//For Assigned Night duration
	$assigned_night = "Select Class_idClass,Venue_idVenue,idTime_Slot from attendance, class, time_slot WHERE Class_idClass = idClass and idTime_Slot = 2 and Time_Slot_idTime_Slot = idTime_Slot 
		 and Venue_idVenue IS NOT Null GROUP BY Class_idClass";
	$assigned_night_result = mysqli_query($link,$assigned_night) or die(mysqli_error($link));
	$assigned_night_array = mysqli_fetch_array($assigned_night_result);
	$assigned_night_row = mysqli_num_rows($assigned_night_result);
	
	
	//check day availabilty
	while ($assigned_venue){
		//assigned day 1-9
		for ($i=1; $i<=9; $i++){
				if($assigned_venue['day0'.$i] != '')
				{
					$assigned_date[$i] = $assigned_venue['day0'.$i];
				}
			}
		//assigned day 10-12	
		for ($i=10; $i<=12; $i++){
				if($assigned_venue['day'.$i] != '')
				{
					$assigned_date[$i] = $assigned_venue['day'.$i];
				}
			}
		//assigning day 1-9	
		for ($k=1; $k<=9; $k++){
				if($assigning_venue['day0'.$k] != '')
				{
					$assigning_date[$k] = $assigning_venue['day0'.$k];
				}
			}
		//assigning day 10-12
		for ($k=10; $k<=12; $k++){
				if($assigning_venue['day'.$k] != '')
				{
					$assigning_date[$k] = $assigning_venue['day'.$k];
				}
			}
		if ($assigned_date[$i] != $assigning_date[$k]){
				//store assigned venue
				$venue_assigned[$i] = $assigned_venue['Venue_idVenue'];
				//Check day duration
				for($l=1;$l<=$assigning_day_row;$l++){
				
						$day_result[$l] = $assigned_day_row['Venue_idVenue'.$l];
					
					
					if ($day_result[$l]!= $venue_assigned[$i])
						
					{	
						$venue_used[$l] = $assigned_day_array['idVenue'.$l];
						$sql3 = "Select * from Venue where idVenue != $venue_used[$l]"
						$result3 = mysqli_query($link,$sql3) or die(mysqli_error($link));
						$row3 = mysqli_fetch_array($result3);
						echo 'TEST1'.$row3['name'];
						
					}
					else {
							for($m=1;$m<=$assigning_night_row;$m++){
								$night_result[$m] = $assigned_night_row['Venue_idVenue'.$m];
								if ($night_result[$m]!= $venue_assigned[$i])
									{
										$venue_used[$m] = $assigned_night_array['idVenue'.$m;
										$sql4 = "Select * from Venue where idVenue != $venue_used[$m]"
										$result4 = mysqli_query($link,$sql4) or die(mysqli_error($link));
										$row4 = mysqli_fetch_array($result4);
										echo 'TEST2'.$row4['name'];
									}
								}
							}
					else
						{
							$sql5 = "Select * from Venue"
							$result5 = mysqli_query($link,$sql5) or die(mysqli_error($link));
							$row5 = mysqli_fetch_array($result5);
							echo 'Test3'.$row5['name'];
						}
				}
			}
		}

?>	

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Assign Class</title>
	</head>
	<body>
			<form name="s1" action="assign_lecturer.php"  method="post">
	
			<h1>Assign Venue</h1>
			<?php
				echo 'Course: '.$row1['name'].'';
				echo '<br/>';
				echo 'Class: '.$class_id.'';
				echo '<input type="hidden" name="class_id" value="'.$class_id.'"/>';
				echo '<input type="hidden" name="no_student" value="'.$no_student.'"/>';

				echo'<table cellpadding="10" border="1" style="border-collapse: collapse">';
				
				echo'<tr>
						<th>students</th>
						<th>Venue</th>
					</tr>';
				
				If ($assigning_no == 1)
				{
					for ($i=1; $i<=$no_student; $i++)
					echo '<tr>';
					echo '<th>'.$student_name['name'].'</th>';
					
					echo '</tr>';
					
				}
					
				echo '</table>';
			?>
			</form>
	</body>		
</html>

There alot of codes..so sorry and thanks for the help!

Edited by lf.gene: n/a

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by hielo
0

Thanks! I got no errors now.. But can i ask.. is the way i use loop is incorrect method? how come i getting too much repeating of answer? that causes this error:Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\FYP\assign_venueTest.php on line 82

0

try:

<?php
	$class_id = $_GET['id'];
	$HOST = 'localhost';
	$USERNAME = 'root';
	$PASSWORD = '';
	$DB = 'sjas';
	$link = mysqli_connect($HOST,$USERNAME,$PASSWORD,$DB);
	
	//get class
	$sql1 = "SELECT * FROM class,course WHERE idClass = $class_id and Course_idCourse = idCourse";
	$result1 = mysqli_query($link,$sql1) or die(mysqli_error($link));
	$row1 = mysqli_fetch_array($result1);
	
	//get students
	$sql2 = "SELECT * FROM member m,attendance a WHERE Class_idClass = $class_id and Member_idMember = idMember group by idMember";
	$result2 = mysqli_query($link,$sql2) or die(mysqli_error($link));
	$no_student = mysqli_num_rows($result2);
	$student_name = mysqli_fetch_array($result2);
	
	//Get information of assigning class
	$assigning = "Select Class_idCLass,Venue_idVenue,day01,day02,day03,day04,day05,day06,day07,day08,day09,day10,day11,day12 from attendance, class where Venue_idVenue IS NULL and Class_idClass = $class_id group by Class_idClass";
	$assigning_result = mysqli_query($link,$assigning) or die(mysqli_error($link));
	$assigning_no = mysqli_num_rows($assigning_result);
	$assigning_venue = mysqli_fetch_array($assigning_result);
	
	//For Assigning Day duration
	$assigning_day = "Select Class_idCLass,Venue_idVenue,idVenue, idTime_Slot from attendance, class, time_slot, venue where Venue_idVenue IS NULL and Class_idClass = $class_id and idTime_Slot = 1 group by Class_idClass";
	$assigning_day_result = mysqli_query($link,$assigning_day) or die(mysqli_error($link));
	$assigning_no = mysqli_num_rows($assigning_day_result);
	$assigning_venue = mysqli_fetch_array($assigning__day_result);
	
	//For Assigning Night duration
	$assigning_night = "Select Class_idCLass,Venue_idVenue,idVenue, idTime_Slot from attendance, class, time_slot, venue where Venue_idVenue IS NULL and Class_idClass = $class_id and idTime_Slot = 2 group by Class_idClass";
	$assigning_night_result = mysqli_query($link,$assigning_night) or die(mysqli_error($link));
	$assigning_no = mysqli_num_rows($assigning_night_result);
	$assigning_venue = mysqli_fetch_array($assigning_night_result);
	
	//Get Assigned Venue's information
	$assigned = "Select Class_idCLass,Venue_idVenue,day01,day02,day03,day04,day05,day06,day07,day08,day09,day10,day11,day12 from attendance a,class c where a.Class_idClass is not Null and a.Venue_idVenue is not Null Group by Class_idClass";
	$assigned_result = mysqli_query($link,$assigned) or die(mysqli_error($link));
	$assigned_venue = mysqli_fetch_array($assigned_result);
	$assigned_venue_no = mysqli_num_rows($assigned_result);
	
	//For Assigned Day duration
	$assigned_day = "Select Class_idClass,Venue_idVenue,idTime_Slot from attendance, class, time_slot WHERE Class_idClass = idClass and idTime_Slot = 1 and Time_Slot_idTime_Slot = idTime_Slot and Venue_idVenue IS NOT Null GROUP BY Class_idClass";
	$assigned_day_result = mysqli_query($link,$assigned_day) or die(mysqli_error($link));
	$assigned_day_array = mysqli_fetch_array($assigned_day_result);
	$assigned_day_row = mysqli_num_rows($assigned_day_result);
	
	//For Assigned Night duration
	$assigned_night = "Select Class_idClass,Venue_idVenue,idTime_Slot from attendance, class, time_slot WHERE Class_idClass = idClass and idTime_Slot = 2 and Time_Slot_idTime_Slot = idTime_Slot and Venue_idVenue IS NOT Null GROUP BY Class_idClass";
	$assigned_night_result = mysqli_query($link,$assigned_night) or die(mysqli_error($link));
	$assigned_night_array = mysqli_fetch_array($assigned_night_result);
	$assigned_night_row = mysqli_num_rows($assigned_night_result);
	
	
	//check day availabilty
	if( count($assigned_venue) ){
		//assigned day 1-9
		for ($i=1; $i<=9; $i++){
				if($assigned_venue['day0'.$i] != '')
				{
					$assigned_date[$i] = $assigned_venue['day0'.$i];
				}
			}
		//assigned day 10-12	
		for ($i=10; $i<=12; $i++){
				if($assigned_venue['day'.$i] != '')
				{
					$assigned_date[$i] = $assigned_venue['day'.$i];
				}
			}
		//assigning day 1-9	
		for ($k=1; $k<=9; $k++){
				if($assigning_venue['day0'.$k] != '')
				{
					$assigning_date[$k] = $assigning_venue['day0'.$k];
				}
			}
		//assigning day 10-12
		for ($k=10; $k<=12; $k++){
				if($assigning_venue['day'.$k] != '')
				{
					$assigning_date[$k] = $assigning_venue['day'.$k];
				}
			}
		if ($assigned_date[$i] != $assigning_date[$k]){
				//store assigned venue
				$venue_assigned[$i] = $assigned_venue['Venue_idVenue'];
				//Check day duration
				for($l=1;$l<=$assigning_day_row;$l++){
				
						$day_result[$l] = $assigned_day_row['Venue_idVenue'.$l];
					
					
					if ($day_result[$l]!= $venue_assigned[$i])
						
					{	
						$venue_used[$l] = $assigned_day_array['idVenue'.$l];
						$sql3 = "Select * from Venue where idVenue != $venue_used[$l]";
						$result3 = mysqli_query($link,$sql3) or die(mysqli_error($link));
						$row3 = mysqli_fetch_array($result3);
						echo 'TEST1'.$row3['name'];
						
					}
					else {
							for($m=1;$m<=$assigning_night_row;$m++){
								$night_result[$m] = $assigned_night_row['Venue_idVenue'.$m];
								if ($night_result[$m]!= $venue_assigned[$i])
									{
										$venue_used[$m] = $assigned_night_array['idVenue'.$m;
										$sql4 = "Select * from Venue where idVenue != $venue_used[$m]"
										$result4 = mysqli_query($link,$sql4) or die(mysqli_error($link));
										$row4 = mysqli_fetch_array($result4);
										echo 'TEST2'.$row4['name'];
									}
								}
							}
					else
						{
							$sql5 = "Select * from Venue"
							$result5 = mysqli_query($link,$sql5) or die(mysqli_error($link));
							$row5 = mysqli_fetch_array($result5);
							echo 'Test3'.$row5['name'];
						}
				}
			}
		}

?>	

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Assign Class</title>
	</head>
	<body>
			<form name="s1" action="assign_lecturer.php"  method="post">
	
			<h1>Assign Venue</h1>
			<?php
				echo 'Course: '.$row1['name'].'';
				echo '<br/>';
				echo 'Class: '.$class_id.'';
				echo '<input type="hidden" name="class_id" value="'.$class_id.'"/>';
				echo '<input type="hidden" name="no_student" value="'.$no_student.'"/>';

				echo'<table cellpadding="10" border="1" style="border-collapse: collapse">';
				
				echo'<tr>
						<th>students</th>
						<th>Venue</th>
					</tr>';
				
				If ($assigning_no == 1)
				{
					for ($i=1; $i<=$no_student; $i++)
					echo '<tr>';
					echo '<th>'.$student_name['name'].'</th>';
					
					echo '</tr>';
					
				}
					
				echo '</table>';
			?>
			</form>
	</body>		
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.