slashes problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

slashes problem

Post 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?
SimonEast
Forum Newbie
Posts: 5
Joined: Thu Oct 09, 2003 11:00 am
Location: Melbourne, AUS

Post 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 >
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Post Reply