I'm trying to use a variable within a query WHERE statement, but it shows 0 results. If I directly hard code the text instead of using the variable, it works. The variable is pulling from a $_GET
, and if I echo that variable, it is showing the correct text.
Here's my code:
$Domain = $_GET['Domain'];
$result = mysql_query(SELECT Code, Title, Domain, Status FROM tablename WHERE Domain="$Domain" ORDER BY Code');
If I swap out $Domain
for direct text, like ABC
, it works. I have tried swapping out the quotes and single quotes throughout the statement, removing the quotes around $Domain, concatenating the statement separately.... all yield erros or the same result.
And as stated, if I echo $Domain
, it shows ABC
(or whatever it's supposed to show), so I know it's pulling correctly from the $_GET
.
Anyone know what I'm doing wrong?