WHERE clause seems to be messing up FIELD function I'm trying to do a simple query but just can't get it to work and can't find an answer online that's working correctly.  All I want to do is query a table with a where clause, then order those results based on some value.  Here is the query:
SELECT * FROM reservation_form_results
    WHERE campaign_id = $campaignId
    ORDER BY FIELD(status, '$sortValue')

Here is what the data looks like (id is an int, campaign_id is an int, and status is an enum where the values default to undecided, but include good_fit, bad_fit, added):
id | campaign_id | status
----------------------------
 1 |          80 | good_fit
 2 |          80 | good_fit
 3 |          81 | bad_fit
 4 |          85 | added
 5 |          80 | added
 6 |          80 | bad_fit
 7 |          85 | undecided

Any thoughts on what could be going wrong?  It currently works if I remove either the where clause or the Field function.  Thanks
I didn't know MySQL understood &quot;$campaignid&quot; as a variable, in the examples I see &quot;@&quot; being used, as in &quot;@campaignid&quot;.
Anyway, in stead of FIELD (which needs a list of arguments, not an argument containing a list) I'd use LOCATE, with sortValue containing &quot;good_fit,bad_fit,added,undecided&quot;:
SELECT * FROM reservation_form_results
    WHERE campaign_id = $campaignId
    ORDER BY locate(status, '$sortValue')

&quot;undecided&quot; will have the highest location, preceded by added, etc.
db fiddle
PHP MySQL prepared statements