Originally posted by VanPEP
thats what I already had, but connecting to the database is not my problem, its selecting the info I want, this is the line giving me trouble:
$result = mysql_query("select * from Team_Data where LOCATION = Away AND PLAYERS = 12");
while ($row = mysql_fetch_object($result))
if I just use
$result = mysql_query("select * from Team_Data");
while ($row = mysql_fetch_object($result))
it works fine at displaying everything in the Team_Data table, but thats not what I want, I only want specific info like what I am trying to do with the first example of the line
VanPEP,
First of all, you DO need single quotes around 'Away', as you will find if you consult the SQL documentation, as several people have pointed out. Second of all, in the examples you've posted, you are using mysql_query instead of mysql_db_query (it shouldn't matter, but after you've tried quotes, you're left with few other variables that could be causing the problem). If you want to try the other query method, DigitalExp. had it pretty much right with the above example with the exception of one thing: he/she reversed the order of the elements in the mysql_db_query statement; the database name comes first and the query string comes second. I recommend setting the query string to a variable and doing it that way to make your code easier to read, too.
Try this one: (the database connection code is fine, so I'll start with where you are having the problem)
$query = "SELECT * from Team_Data WHERE LOCATION = 'Away' AND PLAYERS = '12'";
//You said your field names are not in all caps...yet you post your examples with them in all caps
//They are case sensitive as a bunch of people have said, so be aware of that when you try this
$result = mysql_db_query($Team_Data, $query) or die ("The following query failed: " . $query);
Keep us posted (no pun intended)!