Hi frnds...

here i m doing search for my website...

$mcat='abc';

$query="SELECT * FROM news WHERE topic LIKE '%$mcat%' ";

here , the problem is in my db table $mcat value stored as doublequotes ...the word itself having double qoutes....

the above query working for all other sarch items, except double quotes words...plz give me some suggestions...

Thanks in advance...
Saritha...

Recommended Answers

All 8 Replies

use mysql_real_escape_string()

you can use escape character

i/'ll 
something like this will work

you can even change the table to one without a quotation mark. hope it helps.shalom shalom

$mcat = mysql_real_escape_string($mcat);
$query="SELECT * FROM news WHERE topic LIKE '%$mcat%' ";

using addslash() is also a easy choice

$mcat = mysql_real_escape_string($mcat);
$query="SELECT * FROM news WHERE topic LIKE '%$mcat%' ";

Hi ...

I already test mysql_real_escape_string($mcat)...but not working...
In my db th first letter if having "...
eg:

"hi" welcome...


but $mcat= 'hi';

it doesnt search...

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."' ");

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."' ");

Hi Network...i got it...

Thanks...i mis used ur suggestion...

now ok..its working...
Thanks once again...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.