Search code examples
phpquotes

Converting double quotes to single quotes


I am little stuck today trying to convert double quote into single quote.

I got this:

$string=" WHERE news_cat='$catid' AND news_title LIKE '%$searchnews%'";

I did this but it didn't work:

$string = ' WHERE `news_cat` = \'' . $catid . '\' AND `news_title` LIKE '%$searchnews%'';

Solution

  • You also need to escape the last single quotes:

    LIKE \'%'.$searchnews.'%\'';