I'm trying to run a query like the following example:
$activity = $HTTP_POST_VARS["activity"]; $sql = "SELECT first, last, email FROM student_involvement WHERE " . $activity . " = 1"; $result = mysql_query($sql) or die(mysql_error());
The variable $activity is pulling a column name from a predefined select list of activities. Each one of these fields is an int field and if it is true it will have a 1 false a 0. The query fails:
SELECT first, last, email FROM student_involvement WHERE acapella = 1
EXPORT ERROR:Unknown column 'acapella' in 'where clause'
Does anyone know why this is failing? The columns exist, I can pull general data from that table, but it seems to throw errors when I try to implement a WHERE clause...
Thanks for all of your help in advance!