0
$result = mysql_query("SELECT * FROM Volunteers WHERE Volunteers.eventID = " . $var);

$sql = mysql_query("SELECT * FROM Members WHERE Members.pid = " . $temp);

I am also doing or die(mysql_error()) at the end of both statements if that matter. My problem is that the first statement executes perfectly but in that table I store an attribute called pid. So the second statement is supposed to take that and return the row where it equals that pid so I can get the name. I get an error that says unknown column in 'a2' in 'where clause' where a2 the pid attribute returned from the first statement. Thanks for any help!

EDIT: Figured out what was wrong. Had to write the code like this:

$sql = mysql_query("SELECT * FROM Members WHERE Members.pid = '$temp'") or   die(mysql_error());
ranzy
  • 459
  • 3
  • 6
  • 10
  • IT may help if you provide more code, you are not telling us where you get this value for $temp. It is probably to do with that. – thecoshman Apr 14 '10 at 07:03

1 Answers1

0

I think I see what you are trying to do, you can do this in one query, by JOIN-ing the tables together. the SQL query should be something like

SELECT Members.* FROM Members INNER JOIN Volunteers ON Volunteers.eventID=Members.pid WHERE Volunteers.eventID=" . $var

Check out This for a basic introduction to SQL joins.

thecoshman
  • 8,394
  • 8
  • 55
  • 77