use mysql_real_escape_string()
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
$mcat = mysql_real_escape_string($mcat);
$query="SELECT * FROM news WHERE topic LIKE '%$mcat%' ";
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
using addslash() is also a easy choice
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
sorry i don't agree with it, if the search string is 'hi' like $var = 'hi' and in your db there are below entries -
1.high
2.hi
3."hi!
4."hi"
all these will come in the query's result if done with -
mysql_query("select * from tbl where fieldName like '%".$var."' ");
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76