mysql - PHP Mysqli with hyphen


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.




try withhtmlspecialchars(); function.

it should fixed for you,

$query = "SELECT * FROM topic WHERE title LIKE '%htmlspecialchars($name)%'";

People are also looking for solutions to the problem: php - Woocommerce one page checkout custom


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.