leerik Posted December 15, 2006 Share Posted December 15, 2006 I know I should be looking for a missing semicolon here or something, but I just can't seem to find where my syntax is wrong. My error message is this...Parse error: syntax error, unexpected T_VARIABLE in /home/www/s3/spy1u674/html/LA4squarestats/admin/roundscourts_teams.php on line 213And here's my code (the last line with the bracket is line 213) if($teams == "1") { $player0team = $_POST['player0team']; //determining if player 0 already has stats listed for this match/round/court $player0_team_modifyoradd = mysql_query("SELECT LA4square_team_stats.TStatsPlayerNum AS teamplayerid FROM LA4square_team_stats WHERE LA4square_team_stats.TStatsPlayerNum = '$player0num' AND LA4square_team_stats.TStatsTeamID = '$player0team' AND LA4square_team_stats.TStatsSeasonID = '$season_id' AND LA4square_team_stats.TStatsMatchID = '$matchid' AND LA4square_team_stats.TStatsMatchRound = '$rounds_select' AND LA4square_team_stats.TStatsMatchCourt = '$courts_select'", $connection) or die(mysql_error()); if(mysql_num_rows($player0_team_modifyoradd) == 0) {Any help? Thanks! Quote Link to comment Share on other sites More sharing options...
marcus Posted December 15, 2006 Share Posted December 15, 2006 You never ended the first if statement[code] if($teams == "1") { $player0team = $_POST['player0team']; //determining if player 0 already has stats listed for this match/round/court $player0_team_modifyoradd = mysql_query("SELECT LA4square_team_stats.TStatsPlayerNum AS teamplayerid FROM LA4square_team_stats WHERE LA4square_team_stats.TStatsPlayerNum = '$player0num' AND LA4square_team_stats.TStatsTeamID = '$player0team' AND LA4square_team_stats.TStatsSeasonID = '$season_id' AND LA4square_team_stats.TStatsMatchID = '$matchid' AND LA4square_team_stats.TStatsMatchRound = '$rounds_select' AND LA4square_team_stats.TStatsMatchCourt = '$courts_select'", $connection) or die(mysql_error()); } if(mysql_num_rows($player0_team_modifyoradd) == 0) {[/code] Quote Link to comment Share on other sites More sharing options...
leerik Posted December 15, 2006 Author Share Posted December 15, 2006 the first if statement ends much later. can you not nest if statements like that? Quote Link to comment Share on other sites More sharing options...
marcus Posted December 15, 2006 Share Posted December 15, 2006 Oh, you should have said that :P Quote Link to comment Share on other sites More sharing options...
leerik Posted December 15, 2006 Author Share Posted December 15, 2006 sorry! ;D should i remove that second bracket to actually nest the second if statement? Quote Link to comment Share on other sites More sharing options...
marcus Posted December 15, 2006 Share Posted December 15, 2006 The whole code looks fine[code] if($teams == 1) { $player0team = $_POST['player0team']; //determining if player 0 already has stats listed for this match/round/court $player0_team_modifyoradd = mysql_query("SELECT LA4square_team_stats.TStatsPlayerNum AS teamplayerid FROM LA4square_team_stats WHERE LA4square_team_stats.TStatsPlayerNum = $player0num AND LA4square_team_stats.TStatsTeamID = $player0team AND LA4square_team_stats.TStatsSeasonID = $season_id AND LA4square_team_stats.TStatsMatchID = $matchid AND LA4square_team_stats.TStatsMatchRound = '$rounds_select' AND LA4square_team_stats.TStatsMatchCourt = '$courts_select'", $connection) or die(mysql_error()); if(mysql_num_rows($player0_team_modifyoradd) == 0) {[/code] Quote Link to comment Share on other sites More sharing options...
leerik Posted December 15, 2006 Author Share Posted December 15, 2006 that's what i thought! :) and yet, i still get the error. should i post more of the code preceding this? Quote Link to comment Share on other sites More sharing options...
marcus Posted December 15, 2006 Share Posted December 15, 2006 please Quote Link to comment Share on other sites More sharing options...
Albright Posted December 15, 2006 Share Posted December 15, 2006 Man, you use some long variable names.Instead of just posting code preceding it, could you post the code after as well?What happens when you cram that long SQL statement call function all in one line? Does PHP still call out the line with the bracket as faulty? Quote Link to comment Share on other sites More sharing options...
leerik Posted December 15, 2006 Author Share Posted December 15, 2006 All right, here's a bunch of code for ya... The line in question is right after "if(mysql_num_rows($player0_team_modifyoradd) == 0)"I'll try putting the SQL statement on one line, but as you can see, i've done a lot of them on seperate lines that seem to work fine... } else { //if the player _does_ have stats for this m/r/c, then update them if($player0points != "") { mysql_query("UPDATE LA4square_points SET PointsAmount = '$player0points' WHERE PointsPlayerNumber = '$player0num' AND PointsMatchCourt = '$courts_select' AND PointsMatchRound = '$rounds_select' AND PointsMatchID = '$matchid' AND PointsSeasonID = '$season_id'", $connection) or die(mysql_error()); } if($player0entries != "") { mysql_query("UPDATE LA4square_entries SET EntriesAmount = '$player0entries' WHERE EntriesPlayerNumber = '$player0num' AND EntriesMatchCourt = '$courts_select' AND EntriesMatchRound = '$rounds_select' AND EntriesMatchID = '$matchid' AND EntriesSeasonID = '$season_id'", $connection) or die(mysql_error()); } if($player0aces != "") { mysql_query("UPDATE LA4square_aces SET AcesAmount = '$player0aces' WHERE AcesPlayerNumber = '$player0num' AND AcesMatchCourt = '$courts_select' AND AcesMatchRound = '$rounds_select' AND AcesMatchID = '$matchid' AND AcesSeasonID = '$season_id'", $connection) or die(mysql_error()); } if($player0bodysacs != "") { mysql_query("UPDATE LA4square_bodysacs SET BodySacsAmount = '$player0bodysacs' WHERE BodySacsPlayerNumber = '$player0num' AND BodySacsMatchCourt = '$courts_select' AND BodySacsMatchRound = '$rounds_select' AND BodySacsMatchID = '$matchid' AND BodySacsSeasonID = '$season_id'", $connection) or die(mysql_error()); } if($player0style != "") { mysql_query("UPDATE LA4square_stylepoints SET StylePointsAmount = '$player0style' WHERE StylePointsPlayerNumber = '$player0num' AND StylePointsMatchCourt = '$courts_select' AND StylePointsMatchRound = '$rounds_select' AND StylePointsMatchID = '$matchid' AND StylePointsSeasonID = '$season_id'", $connection) or die(mysql_error()); } } if($teams == "1") { $player0team = $_POST['player0team']; //determining if player 0 already has stats listed for this match/round/court $player0_team_modifyoradd = mysql_query("SELECT LA4square_team_stats.TStatsPlayerNum AS teamplayerid FROM LA4square_team_stats WHERE LA4square_team_stats.TStatsPlayerNum = '$player0num' AND LA4square_team_stats.TStatsTeamID = '$player0team' AND LA4square_team_stats.TStatsSeasonID = '$season_id' AND LA4square_team_stats.TStatsMatchID = '$matchid' AND LA4square_team_stats.TStatsMatchRound = '$rounds_select' AND LA4square_team_stats.TStatsMatchCourt = '$courts_select'", $connection) or die(mysql_error()); if(mysql_num_rows($player0_team_modifyoradd) == 0) { //if the player has no stats for this particular match/round/court/team, create them! mysql_query("INSERT INTO LA4square_team_stats SET TStatsPlayerNum = '$player0num', TStatsTeamID = '$player0team', TStatsMatchCourt = '$courts_select', TStatsMatchRound = '$rounds_select', TStatsMatchID = '$matchid', TStatsSeasonID = '$season_id', TStatsPoints = '$player0points', TStatsEntries = '$player0entries', TStatsAces = '$player0aces', TStatsBodySacs = '$player0bodysacs', TStatsStylePoints = '$player0style', "$connection) or die(mysql_error()); } else Quote Link to comment Share on other sites More sharing options...
marcus Posted December 15, 2006 Share Posted December 15, 2006 well for one, the fourth to last line is wrong, you need to end the query first then comma then $connection.and is AS even part of the SQL Syntax? Quote Link to comment Share on other sites More sharing options...
leerik Posted December 15, 2006 Author Share Posted December 15, 2006 Sweet! you got it! it was that fourth-to-last line, i suppose. Thanks!!Yeah, I use the AS in SQL for later appropriation in arrays. Quote Link to comment Share on other sites More sharing options...
marcus Posted December 15, 2006 Share Posted December 15, 2006 No problem :D Quote Link to comment Share on other sites More sharing options...
btherl Posted December 15, 2006 Share Posted December 15, 2006 As a rule of thumb, a syntax error on line X really means "Anywhere before line X". And the easiest way to fix it is to use an editor which has php syntax highlighting. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.