mysql - PHP Mysqli with hyphen
146
I have a query problem with hyphen character in search word.
$name = "%{$name}%";
$query = "SELECT * FROM `topic` WHERE `title` LIKE '$name'";
Variable$name
like this%Preacher - first%
dynamically.
But if it is dynamic this doesn't work. If I use like text, this doesn't work.
Answer
Solution:
try with
htmlspecialchars();
function.it should fixed for you,
$query = "SELECT * FROM topic WHERE title LIKE '%htmlspecialchars($name)%'";