Jump to content

ergi depracation error - trying to update to preg_match


simcoweb

Recommended Posts

We have a client using an OLD version of Xcart that's throwing errors regarding eregi depracation due to it being written for prior to MySQL 5.3. We've run into this problem before but were able to find some examples and solutions  for converting to a preg_match updated syntax. However, this one has me a bit baffled since it doesn't fit the syntax of most of the examples and no matter how I insert the delimiters it throws an error.

 

This is the line throwing the error:

 

if (eregi("^(http|ftp)://", $v["image_path"]))

 

I've used these examples in the past for converting from eregi to preg_match: http://www.devthought.com/2009/06/09/fix-ereg-is-deprecated-errors-in-php-53/

 

But this sliver of code has an untypical format to how it's expressed. So no matter what I've tried I just can't get it right. Any help would be MUCH appreciated!

Link to comment
Share on other sites

based on that link you provided, my guess is you tried to use / as the delimiter and then didn't escape it, since you use it in your actual pattern.  preg_match can use pretty much any non-alphanumeric character as the delimiter, but whatever you choose must be escaped if you need to use it in the actual pattern. 

Link to comment
Share on other sites

.josh, I may have spoken too soon. Suddenly there's this error appearing:

 

Warning: Division by zero in /home/wwwpipet/public_html/shop/modules/Detailed_Product_Images/product_images.php on line 57

Warning: preg_match() [function.preg-match]: Empty regular expression in /home/wwwpipet/public_html/shop/modules/Detailed_Product_Images/product_images.php on line 57

 

That's the same line as before but when I first implemented your code modification on the test product I was viewing all errors went away. This is another product page i'm viewing, same cart, however.

 

Now, there are two other mentions of eregi on the page in a location ahead of the line we fixed, line 57. Here's lines 44 - 49:

 

if ($current_area != "C" && is_array($images)) {
foreach($images as $k=>$v) {
	$images[$k]["type"] = (eregi("gif",$v["image_type"])?"GIF":(eregi("png",$v["image_type"])?"PNG":"JPG"));
}

}

 

But, these lines are NOT the ones mentioned in the error message. Only 57 is. But, the line 57 error is now different than the original. Ideas?

 

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.