Page 1 of 1

Hi trouble with str_replace and search query

Posted: Wed Feb 04, 2009 4:33 am
by sanju
Hi all,

I am doing a search functionality.I need to get data entered with ', 5 etc..
So after entering data in search filed

The keyword is converetd to

Code: Select all

  $variable=str_replace("'","%\'",$variable);
[ /code] 
    Then  quotes problem is solved   then I need %  to work

  Now when entering % all fields are displaying   . how I should remove that..

     Regrads

Re: Hi trouble with str_replace and search query

Posted: Wed Feb 04, 2009 1:19 pm
by mickeyunderscore
Could you try and explain a bit better? Maybe show me some code or your database query?

Re: Hi trouble with str_replace and search query

Posted: Wed Feb 04, 2009 1:43 pm
by Benjamin
% is a mysql wild card in LIKE queries. That will display all records.

Re: Hi trouble with str_replace and search query

Posted: Wed Feb 04, 2009 10:21 pm
by sanju
Use javascript to remove % is that better or any other methods in PHP?

Re: Hi trouble with str_replace and search query

Posted: Thu Feb 05, 2009 3:08 am
by mickeyunderscore
No, if you want to properly validate user input use PHP. JavaScript can be disabled.