2014-10-05 140 views
0

今天我试图将双引号转换为单引号。将双引号转换为单引号

我得到这个:

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

我这样做,但它没有工作:

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

回答

1

您还需要躲避最后单引号:

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

谢谢很多!我非常亲密,但从来没有想过这样做。大声笑 – user2583893 2014-10-05 12:59:25

+0

不客气,请接受我的答案,如果你认为它解决了你的问题。 – Cyclonecode 2014-10-05 13:00:09

+0

我不知道你是否可以在这里帮助这个http://stackoverflow.com/questions/26161065/negative-value-error-in-limit-clause:这整个文件www.bestbuildpc.org/bugfiles/index.txt – user2583893 2014-10-05 13:17:30