Jump to content

Can't find where i went wrong =/ PARSE ERROR


mafia2005

Recommended Posts

Parse error: syntax error, unexpected T_ELSE in add_upcoming_match.php on line 171

I've can't figure out where i went wrong, if anyone could help i would really appreciate it.

 

 

I've searched for extra brackets, semicolumns, and others but i cant seem to find them.

Anyways, here it is

<?php
checkUser('3');
switch($_GET['step']){
	default :
		echo "
	<tr>
		<td class=\"header\" colspan=\"2\">
			<span class=\"header\">Add upcoming match</span>
		</td>
	</tr>
		<form action=\"index.php?content=admin&view=add_upcoming_match\" method=\"post\">
		<tr>
			<td class=\"list\">
				<span class=\"list\">Opponent : </span>
			</td>
			<td class=\"listed\">
				<input type=\"text\" name=\"add_up_match_opponent\" class=\"text\">
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Map : </span>
			</td>
			<td class=\"listed\">
				<input type=\"text\" name=\"add_up_match_map\" class=\"text\">
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">HLTV : </span>
			</td>
			<td class=\"listed\">
				<input type=\"text\" name=\"add_up_match_hltv\" class=\"text\">
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Division : </span>
			</td>
			<td class=\"listed\">
				<select name=\"add_up_match_division\">
					<option value=\"\"></option>
				";
					$add_up_match_divisions_sql = mysql_query("SELECT * FROM ".$table_suffixe."divisions ORDER BY game_name ASC");
					while($add_up_match_division_row = mysql_fetch_array($add_up_match_divisions_sql)){
						echo "
							<option value=\"$add_up_match_division_row[division_id]\">$add_up_match_division_row[game_name]</option>
						";
					}
				echo "
				</select>
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Competition : </span>
			</td>
			<td class=\"listed\">
				<select name=\"add_up_match_competition\">
					<option value=\"\"></option>
				";
				$competitions_sql = mysql_query("SELECT * FROM ".$table_suffixe."competitions ORDER BY name ASC");
				while($competition_row = mysql_fetch_array($competitions_sql)){
					echo "
						<option value=\"$competition_row[competition_id]\">$competition_row[name]</option>
					";
				}
				echo "
				</select>
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Date : </span>
			</td>
			<td class=\"listed\">
				<select name=\"add_up_match_date_day\">
					<option value=\"\">Day</option>
				";
				for($rr=1;$rr<=31;$rr++){
					echo "
						<option value=\"$rr\">$rr</option>
					";
				}
				echo "
					</select>
					/
				";
				$months[1] = 'January';
				$months[2] = 'February';
				$months[3] = 'March';
				$months[4] = 'April';
				$months[5] = 'May';
				$months[6] = 'June';
				$months[7] = 'July';
				$months[8] = 'August';
				$months[9] = 'September';
				$months[10] = 'October';
				$months[11] = 'November';
				$months[12] = 'December';
				echo "
					<select name=\"add_up_match_date_month\">
						<option value=\"\">Month</option>
				";					
				for($rmo=1;$rmo<=12;$rmo++){
					echo "
						<option value=\"$rmo\">$months[$rmo]</option>
					";
				}
				echo "
				</select>
				/
				<select name=\"add_up_match_date_year\">
					<option value=\"\">Year</option>
				";					
				for($rmy=date("Y",time());$rmy<=(date("Y",time())+1);$rmy++){
					echo "
						<option value=\"$rmy\">$rmy</option>
					";
				}
				echo "
				</select>
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Time : </span>
			</td>
			<td class=\"listed\">
				<select name=\"add_up_match_date_hour\">
					<option value=\"\">Hour</option>
				";
				for($rh=1;$rh<=24;$rh++){
					echo "
						<option value=\"$rh\">$rh</option>
					";
				}
				echo "
				</select>
				:
				<select name=\"add_up_match_date_minutes\">
					<option value=\"\">Minutes</option>
				";
				for($rm = 1;$rm <= 59; $rm++){
					if($rm%15==0){
						echo "
							<option value=\"$rm\">$rm</option>
						";
					}
				}
				echo "
				</select>
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Comments : </span>
			</td>
			<td class=\"listed\">
				<textarea name=\"add_up_match_comments\" class=\"textarea\" rows=\"10\"></textarea>
			</td>
		</tr>
		<tr>
			<td colspan=\"2\" class=\"submit\">
				<input type=\"hidden\" value=\"true\" name=\"add_verify\">
				<input type=\"submit\" value=\"Submit\" class=\"submit\">
			</td>
		</tr>
	";
}
else {
	$add_up_match_final_date = mktime($_POST['add_up_match_date_hour'], $_POST['add_up_match_date_minutes'], 0, $_POST['add_up_match_date_month'], $_POST['add_up_match_date_day'], $_POST['add_up_match_date_year']);
	$add_up_match_comments_good = addslashes(nl2br($_POST['add_up_match_comments']));
	mysql_query("INSERT INTO ".$table_suffixe."upcoming_matches (opponent, date, map, competition_id, division_id, comments, hltv) VALUES ('$_POST[add_up_match_opponent]', $add_up_match_final_date, '$_POST[add_up_match_map]', $_POST[add_up_match_competition], $_POST[add_up_match_division], '$add_up_match_comments_good', '$_POST[add_up_match_hltv]')");
	echo "
		<tr>
			<td style=\"padding:5px;\">
				Your match has been added. You will now be redirected to your administration panel.
				<meta http-equiv=\"refresh\" content=\"2;url=index.php?content=admin&view=panel\"> 
			</td>
		</tr>
	";
}
echo "
	<tr>
		<td colspan=\"2\" class=\"page_footer\">
		</td>
	</tr>
";
?>

Link to comment
https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/
Share on other sites

You cannot have an ELSE without an IF.

 

there's an IF before the ELSE though.

 

Please point out where that is.

 

 


<?php
checkUser('3');
if (isset($_GET['step'])){
		echo "
	<tr>
		<td class=\"header\" colspan=\"2\">
			<span class=\"header\">Add upcoming match</span>
		</td>
	</tr>
		<form action=\"index.php?content=admin&view=add_upcoming_match\" method=\"post\">
		<tr>
			<td class=\"list\">
				<span class=\"list\">Opponent : </span>
			</td>
			<td class=\"listed\">
				<input type=\"text\" name=\"add_up_match_opponent\" class=\"text\">
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Map : </span>
			</td>
			<td class=\"listed\">
				<input type=\"text\" name=\"add_up_match_map\" class=\"text\">
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">HLTV : </span>
			</td>
			<td class=\"listed\">
				<input type=\"text\" name=\"add_up_match_hltv\" class=\"text\">
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Division : </span>
			</td>
			<td class=\"listed\">
				<select name=\"add_up_match_division\">
					<option value=\"\"></option>
				";
					$add_up_match_divisions_sql = mysql_query("SELECT * FROM ".$table_suffixe."divisions ORDER BY game_name ASC");
					while($add_up_match_division_row = mysql_fetch_array($add_up_match_divisions_sql)){
						echo "
							<option value=\"$add_up_match_division_row[division_id]\">$add_up_match_division_row[game_name]</option>
						";
					}
				echo "
				</select>
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Competition : </span>
			</td>
			<td class=\"listed\">
				<select name=\"add_up_match_competition\">
					<option value=\"\"></option>
				";
				$competitions_sql = mysql_query("SELECT * FROM ".$table_suffixe."competitions ORDER BY name ASC");
				while($competition_row = mysql_fetch_array($competitions_sql)){
					echo "
						<option value=\"$competition_row[competition_id]\">$competition_row[name]</option>
					";
				}
				echo "
				</select>
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Date : </span>
			</td>
			<td class=\"listed\">
				<select name=\"add_up_match_date_day\">
					<option value=\"\">Day</option>
				";
				for($rr=1;$rr<=31;$rr++){
					echo "
						<option value=\"$rr\">$rr</option>
					";
				}
				echo "
					</select>
					/
				";
				$months[1] = 'January';
				$months[2] = 'February';
				$months[3] = 'March';
				$months[4] = 'April';
				$months[5] = 'May';
				$months[6] = 'June';
				$months[7] = 'July';
				$months[8] = 'August';
				$months[9] = 'September';
				$months[10] = 'October';
				$months[11] = 'November';
				$months[12] = 'December';
				echo "
					<select name=\"add_up_match_date_month\">
						<option value=\"\">Month</option>
				";					
				for($rmo=1;$rmo<=12;$rmo++){
					echo "
						<option value=\"$rmo\">$months[$rmo]</option>
					";
				}
				echo "
				</select>
				/
				<select name=\"add_up_match_date_year\">
					<option value=\"\">Year</option>
				";					
				for($rmy=date("Y",time());$rmy<=(date("Y",time())+1);$rmy++){
					echo "
						<option value=\"$rmy\">$rmy</option>
					";
				}
				echo "
				</select>
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Time : </span>
			</td>
			<td class=\"listed\">
				<select name=\"add_up_match_date_hour\">
					<option value=\"\">Hour</option>
				";
				for($rh=1;$rh<=24;$rh++){
					echo "
						<option value=\"$rh\">$rh</option>
					";
				}
				echo "
				</select>
				:
				<select name=\"add_up_match_date_minutes\">
					<option value=\"\">Minutes</option>
				";
				for($rm = 1;$rm <= 59; $rm++){
					if($rm%15==0){
						echo "
							<option value=\"$rm\">$rm</option>
						";
					}
				}
				echo "
				</select>
			</td>
		</tr>
		<tr>
			<td class=\"list\">
				<span class=\"list\">Comments : </span>
			</td>
			<td class=\"listed\">
				<textarea name=\"add_up_match_comments\" class=\"textarea\" rows=\"10\"></textarea>
			</td>
		</tr>
		<tr>
			<td colspan=\"2\" class=\"submit\">
				<input type=\"hidden\" value=\"true\" name=\"add_verify\">
				<input type=\"submit\" value=\"Submit\" class=\"submit\">
			</td>
		</tr>
	";
}
else {
	$add_up_match_final_date = mktime($_POST['add_up_match_date_hour'], $_POST['add_up_match_date_minutes'], 0, $_POST['add_up_match_date_month'], $_POST['add_up_match_date_day'], $_POST['add_up_match_date_year']);
	$add_up_match_comments_good = addslashes(nl2br($_POST['add_up_match_comments']));
	mysql_query("INSERT INTO ".$table_suffixe."upcoming_matches (opponent, date, map, competition_id, division_id, comments, hltv) VALUES ('$_POST[add_up_match_opponent]', $add_up_match_final_date, '$_POST[add_up_match_map]', $_POST[add_up_match_competition], $_POST[add_up_match_division], '$add_up_match_comments_good', '$_POST[add_up_match_hltv]')");
	echo "
		<tr>
			<td style=\"padding:5px;\">
				Your match has been added. You will now be redirected to your administration panel.
				<meta http-equiv=\"refresh\" content=\"2;url=index.php?content=admin&view=panel\"> 
			</td>
		</tr>
	";
}
echo "
	<tr>
		<td colspan=\"2\" class=\"page_footer\">
		</td>
	</tr>
";
?>

 

I bet the code above will not give you a parse error, because wow there is an if before the else after I modified it.

 

Why exactly where you using the switch statement with only "1" default case and no others?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.