mafia2005 Posted July 25, 2007 Share Posted July 25, 2007 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 More sharing options...
per1os Posted July 25, 2007 Share Posted July 25, 2007 Your using else with a switch statement. It doesn't work like that. If/Else Switch/Case Link to comment https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/#findComment-307164 Share on other sites More sharing options...
thiggins09 Posted July 25, 2007 Share Posted July 25, 2007 Also just a suggestion, instead of using a " for outputting your HTML, use a ' , this way you don't need to comment out every " Link to comment https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/#findComment-307167 Share on other sites More sharing options...
mafia2005 Posted July 25, 2007 Author Share Posted July 25, 2007 Your using else with a switch statement. It doesn't work like that. If/Else Switch/Case Sorry, i'm new to this, i did try using switch but it didn't work. Link to comment https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/#findComment-307174 Share on other sites More sharing options...
mafia2005 Posted July 25, 2007 Author Share Posted July 25, 2007 As far as i know, the IF statement is followed by an ELSE.. However, i'm new to this =/ Link to comment https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/#findComment-307192 Share on other sites More sharing options...
maxudaskin Posted July 25, 2007 Share Posted July 25, 2007 You cannot have an ELSE without an IF. Link to comment https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/#findComment-307212 Share on other sites More sharing options...
markjoe Posted July 25, 2007 Share Posted July 25, 2007 This explains it pretty well: http://www.php.net/manual/en/language.control-structures.php Link to comment https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/#findComment-307225 Share on other sites More sharing options...
mafia2005 Posted July 25, 2007 Author Share Posted July 25, 2007 You cannot have an ELSE without an IF. there's an IF before the ELSE though. Link to comment https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/#findComment-307227 Share on other sites More sharing options...
per1os Posted July 25, 2007 Share Posted July 25, 2007 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? Link to comment https://forums.phpfreaks.com/topic/61700-cant-find-where-i-went-wrong-parse-error/#findComment-307230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.