query not allowing url id
Posted: Sat Apr 25, 2009 5:02 am
Hi,
Heres the code:
I am trying to get the ID from the url eg. categories.php?id=action and it will query action games.
This is what I dont understand, I am trying the above code and if I echo $id it prints the id that is in the url fine, but still doesn't seem to work in the category="$id"... If I change the category to = "action" it works fine, I change it back to = $id and it doesn't, even though it is still works when I echo "$id"...
Any ideas? Im puzzled!
Heres the code:
Code: Select all
$id = mysql_real_escape_string($_GET['id']);
// Performing SQL query
$query = 'SELECT * FROM games WHERE category = "$id" ORDER BY id DESC';This is what I dont understand, I am trying the above code and if I echo $id it prints the id that is in the url fine, but still doesn't seem to work in the category="$id"... If I change the category to = "action" it works fine, I change it back to = $id and it doesn't, even though it is still works when I echo "$id"...
Any ideas? Im puzzled!