I've looked at this query over and over and over and can't figure out what's wrong.
$past_matches_rs = $conn->Execute ( "SELECT REPLACE(team.team_name, ' ', '-') AS team_dashed, date_format(matches.match_date, '%m-%d-%Y')as matchdate, matches.match_id, matches.match_type, matches.match_location, matches.match_opponent, team.team_id, team.team_name, type_match.type_id, type_match.type_match_short FROM matches, team, type_match WHERE matches.match_date < CURDATE() AND matches.match_opponent=team.team_id AND matches.match_type=type_match.type_id AND matches.match_opponent=" . $next_rs->Fields("match_opponent") . " ORDER BY matches.match_date ASC" ) or die ( $conn->ErrorMsg() );
I'm getting this error:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY matches.match_date ASC' at line 1
Any ideas?