LIKE operator with $variable
- by skarama
This is my first question here and I hope it is simple enough to get a quick answer!
Basically, I have the following code:
$variable = curPageURL();
$query = 'SELECT * FROM `tablename` WHERE `columnname` LIKE '$variable' ;
If I echo the $variable, it prints the current page's url( which is a javascript on my page)
Ultimately, what I want, is to be able to make a search for which the search-term is the current page's url, with wildcards before and after. I am not sure if this is possible at all, or if I simply have a syntax error, because I get no errors, simply no result!
I tried :
$query = 'SELECT * FROM `tablename` WHERE `columnname` LIKE '"echo $variable" ' ;
But again, I'm probably missing or using a misplaced ' " ; etc.
Please tell me what I'm doing wrong!