Page 1 of 1

slashes problem

Posted: Thu Oct 09, 2003 11:58 am
by yaron
Hello all,
I have set a small function that allow the user to search for a specific string in my output (just simple html table).
The problem is when the user searches strings with '/' (which he often does)it brings up warning.
Warning: Unknown modifier
I've tried addslashes and strip slashes and quotemeta but with no result.
There is no problem with ''' only with '/'
any thoughts?

Posted: Fri Oct 10, 2003 2:01 am
by SimonEast
Sounds like you're searching using a regular expression. I don't know the syntax off the top of my head, but you should probably escape the slash telling PHP it's a literal, not a modifier (replace it with two maybe??).

< Simon >

Posted: Fri Oct 10, 2003 2:17 am
by volka
you're probably using / as pattern delimiter like

Code: Select all

$pattern = '/'.$userInput.'/';
...preg_match($pattern, ...
if so you have to replace any / by \/ in $userInput before using it.