What seems like a very silly "AND" SQL error

I have a very simple MySQL query and the “AND” is breaking the query. If I remove “pt.country_id = $country_id” the query executes. Or if I remove “pt.procedure_id = $procedure_id” the query executes. If they are both together with the AND statement, it breaks…???

Here is my query:

SELECT d.row_name FROM data as d
				LEFT JOIN procedure_table as pt
				  ON pt.table_id = d.table_id
				WHERE pt.country_id = $country_id AND pt.procedure_id = $procedure_id

Here is the error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’ AND pt.procedure_id = 1’ at line 4

Here is my table structure:

Echo the query so you can see how it looks like with the values instead of the variables. My guess is one of them is empty.

Another thing, if you put WHERE conditions on the second table, the LEFT JOIN becomes an INNER JOIN. So if that’s what you want, use INNER JOIN. If not, put those conditions in the ON clause.

Ahh, that was it, a variable was empty