My first guess is that you're using MySQL 4.0, which does not support subqueries.
You should always check for errors in your PHP code, for instance:
$new_duty_query = mysql_query("SELECT ...");
if (!$new_duty_query) {
die("Error in database query: " . mysql_error());
}
Checking for errors and printing the error message is a crucial part of debugging a web app.
Here's a rewrite of your query that gives the same result but does not use subqueries:
SELECT duty_id, duty_description FROM duties d LEFT OUTER JOIN duties_to_projects p ON d.duty_id = p.duty_id AND p.project_id = $project_id WHERE p.duty_id IS NULL
You should also do something to ensure that the $_GET['project_id'] doesn't break your query. I assume project_id is an integer, so what happens if I were to use your web app and enter a request parameter in the URL like:
project_id=banana!
It'll create a syntax error, and your SQL query won't work.
Don't use request parameters in SQL strings without validating them. For instance:
$project_id = intval(0 + $_GET['project_id']);
Forces the $project_id variable to be an integer.
See
http://www.php.net/manual/en/function.intval.php
Regards,
Bill K.