rajivv
September 17, 2011, 8:45am
1
Hi
These are the lines of code getting errors followin is from cs-cart
Code
if ($partial == true) {
$__tmp = str_replace(array(‘‘, ‘?’, ‘/’), array(’. ’, ‘.’, ‘\/’), $v);
if (preg_match(“/^$__tmp\$/iu”, $elm)) {
$suitable = true;
break;
Error
“Warning: preg_match() [function.preg-match]: Compilation failed: missing ) at offset 16 in core/fn.locations.php on line 156”
Line 156 is if (preg_match(“/^$__tmp\$/iu”, $elm)) {
Please help stuck here
rajivv
September 17, 2011, 1:10pm
2
Let me try what you said and revert
gvre
September 17, 2011, 11:36am
3
rajivv
September 17, 2011, 11:47am
4
Saw that but cant understand the issue cause the syntax looks ok
What is the value of $__temp ?
I googled for that error, and it seems that having a ‘(’ in the regex can be a problem. And the solution should be to pass the regex through preg_quote(). Take a look at the manual: http://www.php.net/preg_quote
gvre
September 17, 2011, 1:25pm
7
guido2004 is right. Try the following
if (preg_match('/^' . preg_quote($__tmp, '/') . '$/iu', $elm)) {
rajivv
September 17, 2011, 1:37pm
8
if (preg_match(‘/^’ . preg_quote($__tmp, ‘/’) . ‘$/iu’, $elm))
This give me an error Parse error: syntax error, unexpected T_ELSE in /home/homeidea/public_html/mall/core/fn.locations.php on line 160
gvre
September 17, 2011, 1:41pm
9
I forgot the {. Try it now.
rajivv
September 17, 2011, 1:47pm
10
U mean use the statement with the {… ok will try the same thanks
rajivv
September 17, 2011, 1:52pm
11
Thanks Gvre and guido works perfectly now…