Jump to content

preg_match() Unknown modifier


SMcClean

Recommended Posts

Hi there,

I am NOT a PHP coder, but I have a site that is written in PHP and I am getting an error that keeps filling up my site cache and I just cannot figure it out - I know it has something to do with my images on the site, but none of them are out of the ordinary (GIFs and JPEGs, the only character apart from letters or numbers that i have used is the "_" and there are no spaces). I have looked around at the error I am getting - but I will be honest in that I dont really understand what the problem is or how to resolve it. Here is the error I get:

 

PHP Warning:  preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Unknown modifier 'C' in /home/smcclean/public_html/includes/modules/additional_images.php on line 48

 

This relates to the following line of code: if(preg_match("/" . $products_image_base . "/i", $file) == 1) {

 

I would really appreciate a steer as to how I could resolve this.

 

Many thanks

Link to comment
Share on other sites

My guess is that your $products_image_base variable contains a '/' character, possibly as a directory separator.  you'd have to print the variable to see what it contains.  Since your using '/' as your regex delimiter, any instances of '/' inside your regex (in the variable) must be escaped by prefixing them with a '\' character. preg_quote should be able to take care of this for you.

 

Link to comment
Share on other sites

Hi,

thank you for your reply. One of my image directories is using the "/" separator. How do I "allow" this to be the case? I am not sure what a regex is......apologies, I really do not know PHP! Is there something I can add to the line of code that allows the use of the "/"?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.