Jump to content

PHP Warning: preg_replace(): Compilation failed


Recommended Posts

Hi,

 

I really hope someone out there can help me with my problems.

 

Each time I tried to click on a product on my website, it keeps showing 500 Server Error. It is only happen when I click on a particular product.

 

I've checked on error_log, it shows the following message:

 

PHP Warning: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Compilation failed: invalid range in character class at offset 24 in /home/justanot/public_html/classes/Tools.php on line 1150

 

and found this on Tools.php line 1150,

// Remove all non-whitelist chars.
if ($allow_accented_chars)
$str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-\pL]/u', '', $str);
else
$str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-]/','', $str);
 
I've tried a few ways that someone out there said it works, but it doesn't work on my side.
 
Can someone please kindly help on this, highly appreciated! Thanks heaps!
Link to comment
Share on other sites

  • 5 months later...

hi

I've checked on error_log, it shows the following message:

[23-Apr-2015 10:27:22 Asia/Tehran] PHP Warning:  preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Compilation failed: invalid range in character class at offset 24 in /home3/fevhopny/public_html/shop/classes/Tools.php on line 1154
 
 
and found this on Tools.php line 1154,
1152 : // Remove all non-whitelist chars.
1153 : if ($allow_accented_chars)
1154 : $str = preg_replace('/[\s\'\:\/\[\]\-]+/', ' ', $str);
1155 : else
1156 : $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-]/','', $str);
1157 : 
1158 : $str = preg_replace('/[\s\'\:\/\[\]-]+/', ' ', $str);
1159 : $str = str_replace(array(' ', '/'), '-', $str);
 
Can someone please kindly help on this, highly appreciated! Thanks
Link to comment
Share on other sites

×
×
  • Create New...