GoneNowBye Posted June 21, 2010 Share Posted June 21, 2010 preg_match_all("/(?:[^\\]|^)(?:\[link:([a-zA-Z0-9=,]*)\])/",stripslashes($_GET['d']),$matches); is my line Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unmatched parentheses at offset 41 in what is going on! i dont get it, please help dont comment on the security of $_GET d this is a local test page, Havok I dont get the error 'tis all Quote Link to comment Share on other sites More sharing options...
kratsg Posted June 21, 2010 Share Posted June 21, 2010 My initial guess is this portion: preg_match_all("/(?:[^\\]|^)(?:\[link:([a-zA-Z0-9=,]*)\])/",stripslashes($_GET['d']),$matches); I believe you need 3 or 4 backslashes (I saw this before) to get a literal backslash. Let me find that post. Edit: Here it is http://www.phpfreaks.com/forums/index.php/topic,301552.msg1427102.html#msg1427102 It's not a bug, you firstly need to account for what PHP thinks is an backslash escape sequence, you then need to account for what PCRE considers an escape sequence. You are using a double quote inside a double quoted string, thus meaning it needs to be escaped, there's one backslash. You then wish to match a backslash in your input string. In order to do this let's say we place a single quote in the string. PHP will see this as escaping the backslash which is supposed to be escaping the double quote, thus you need to escape it to prevent that happening. At this point we have 3 backslashes in our patterns. Out of these 3 only one will survive the PHP interpolation. Meaning the Regex pattern contains a single slash. The PCRE engine will assume this backslash is an escape sequence. In order to counter that we need to make sure 2 make it through the the PCRE engine, the only way to do this is add another 2 into the string. That's 5 backslashes. Quote Link to comment Share on other sites More sharing options...
GoneNowBye Posted June 21, 2010 Author Share Posted June 21, 2010 cheers you are right Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.