using a php variable in the WHERE clause of a mysql query
Posted
by
user1262890
on Stack Overflow
See other posts from Stack Overflow
or by user1262890
Published on 2012-03-18T17:42:46Z
Indexed on
2012/03/18
17:57 UTC
Read the original article
Hit count: 505
I'm running a very simple query that I think should work. The only thing that I haven't done before is put a php variable in the WHERE clause of the query. The variable $X is a numerical value, say 100. When I run this query, I just get a value of 0 returned. Am I doing something obviously stupid?
SELECT generator_64k.n
FROM generator_64k
WHERE generator_64k.n<= '$X'
I've looked around the web and also tried this:
SELECT generator_64k.n
FROM generator_64k
WHERE generator_64k.n<= '" . $X . "'
But this also just returns 0.
Any ideas? Thanks in advance.
© Stack Overflow or respective owner