I'm trying to query a table in my database for the rows in which both the columns home_team and away_team contain a value that is in an array. No such luck, however. My code is as follows.
$new_array = array();
for($i=0;$i<count($ncaa);$i++)
{
// Since some of the values in this array contain apostrophes, escape each value
$new_array[$i] = mysql_real_escape_string($ncaa[$i]);
}
$list = join(",", $new_array);
$query = "SELECT *
FROM ncaa_games
WHERE game_date_int >= '".$limit."'
AND (home_team = '".mysql_real_escape_string($team)."' OR away_team = '".mysql_real_escape_string($team)."')
AND home_team IN (".$list.")
AND away_team IN (".$list.")
ORDER BY game_date_int ASC
LIMIT 1";
$next = mysql_query($query)or die(mysql_error());
I keep in getting an error message reading "ou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''UTSA Roadrunners") AND away_team IN (Albany Great Danes,Binghamton Bear' at line 5"
I have a feeling that this could be something rather simple. But, it's still managing to elude me. Any ideas?
Thanks,
Lance
AND (home_team = '".mysql_real_escape_string($team)."' OR away_team = '".mysql_real_escape_string($team)."')