Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Function ereg_replace() - Found The Fix But In a Pickle!


toyzonline

Recommended Posts

Hello Guys And Gals,

 

Like many I have been suddenly hit with the ereg_replace problem. Swiftly found the fix and applied to the store I was working on and all fine. Then realised it was the same on another of my stores and this one aint so simple:

 

1) Applied the fix and it resolved, however was getting URL_rewrite errors, I was using the old "Search Engine Friendly URL" contribution.

2) Tried to remove the contribution syep by step and more things went wrong.

 

So my query is Can the like of Ultimate SEO 5 be laid ontop ontop of the old contribution easily?

 

As far as I can see the best options I have are:

 

1) Fix the ereg_replace issues and try and fix the old URL contrib

2) Fix the ereg_replace issues and install Ultimate SEO 5 over the old contrib

3) Start again.

 

If start again, if i make a backup of the SQL DB and reinstall OSC using the same DB and then restore will all the products be back in tact with keywords and all? Its just that there are several thousand products which were added manually for formatting and cosmetic reasons.

 

Any input would be fantastic as I aint great at php (well actually i stink....lol)

Complete Newbie On The Learn - Not A Programmer

But Learning As I Go

Link to comment
Share on other sites

While I don't have firsthand experience with either of these SEO contribs, I suspect that they will not play nicely together (i.e., you cannot install one atop the other). I can't think of why a PHP upgrade would affect SEO code, so most likely you did not correctly do one or more ereg* upgrades (these were done manually?). Check your work, and remember that the regular expression pattern (the first argument) needs delimiters such as (but not limited to) '/' around the pattern proper (as well as an 'i' after the closing delimiter, for *i replacements). It's easy to forget to add delimiters in the heat of making these fixes.

Link to comment
Share on other sites

Like many I have been suddenly hit with the ereg_replace problem. Swiftly found the fix and applied to the store I was working on and all fine. Then realised it was the same on another of my stores and this one aint so simple:

 

I don't understand what you mean by "old Search Engine Friendly URL contribution." If it is one of the common ones, then you can turn it off in admin, thus elimiating it as a possible cause of the problem. Some of the older contributions did have ereg code in them so tehy would cause such a problem. But without specifics, it is just guessing. You shouldn't be thinking along the lines of re-installing oscommerce and replacing the database though. You'll just be digging a deeper hole.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Ok I used my back up to put the store back to how it was and re-added the "ereg_replace" fix again.

 

Now the index loads correctly but when you click on any links it just reloads the index and when you navigate direct to an internal address I get the following error:

 

Deprecated: Function ereg_replace() is deprecated in /home/trader/public_html/includes/classes/url_rewrite.php on line 28

 

Here is the line in question:

 
$url = str_replace(' ', '-', ereg_replace('[^[:space:]a-zA-Z0-9_-]', '', $url));

Complete Newbie On The Learn - Not A Programmer

But Learning As I Go

Link to comment
Share on other sites

How could you have "added the ereg_replace fix" when you're getting a warning that there are still ereg_replace calls in the code? Obviously you missed one or more. Note that any instructions you were following, or contributions to do this you installed, are likely only covering the base osC code, and not random contributions/add-ons that you may have. In other words, it's up to you to search through the code for all ereg*, split, and other deprecated functions, and fix them manually.

Link to comment
Share on other sites

How could you have "added the ereg_replace fix" when you're getting a warning that there are still ereg_replace calls in the code? Obviously you missed one or more. Note that any instructions you were following, or contributions to do this you installed, are likely only covering the base osC code, and not random contributions/add-ons that you may have. In other words, it's up to you to search through the code for all ereg*, split, and other deprecated functions, and fix them manually.

 

No the ereg_replace fix only covers the standard install files, therefore the fix does not tell me how to fix the url_rewrite.php file which is not usually used but I am using it with a contribution.

 

I guess I just need someone who knows php to help me fix the ereg_replace issues in the url_rewrite.php. I have had a look and most places the fix is changing "eregi" to "preg" and "/" to "/\" and as you can see neither take place in the line i have quoted as the fault.

Complete Newbie On The Learn - Not A Programmer

But Learning As I Go

Link to comment
Share on other sites

How could you have "added the ereg_replace fix" when you're getting a warning that there are still ereg_replace calls in the code? Obviously you missed one or more. Note that any instructions you were following, or contributions to do this you installed, are likely only covering the base osC code, and not random contributions/add-ons that you may have. In other words, it's up to you to search through the code for all ereg*, split, and other deprecated functions, and fix them manually.

 

Soz MrPhil just re-read your comment and dont know what I read the first time....lol

 

Yes i need to manually fix the ereg issues in the url_rewrite file but plain and simple i dont know how to, hence asking for help

Complete Newbie On The Learn - Not A Programmer

But Learning As I Go

Link to comment
Share on other sites

The code changes needed have been discussed many times on this forum. They are in three parts:

  1. Change the name of the function from ereg or eregi to preg_match, etc.
  2. Change the regular expression string (usually the first argument) to have "delimiters" around the pattern, usually / characters. E.g., "look for this" becomes "/look for this/". That seems to be something many people overlook. If there are already / in the string, either escape them (\ plus /) or use a different character, such as #. Watch out for patterns involving paths, especially (frequently contain /).
  3. If the original form is "case insensitive" (e.g., eregi), add i after the closing delimiter. E.g, eregi("look for this",... becomes preg_match("/look for this/i",...

If you can't find the discussions, see the PHP manual: http://us.php.net/manual/en/migration53.deprecated.php for a list of functions to look for to update.

 

Per your earlier post, the changed line would be

$url = str_replace(' ', '-', preg_replace('/[^[:space:]a-zA-Z0-9_-]/', '', $url));

Link to comment
Share on other sites

Thanx Mr Phil explanation understood and no more ereg errors..

 

However could I pick your brains?

 

Since adding the fix none of the product lins work (i.e. direct from home page cant get in to catagories or shown products) and this is only since changing the ereg things.

 

have a look here:

 

http://www.cheshiretraders.co.uk

Complete Newbie On The Learn - Not A Programmer

But Learning As I Go

Link to comment
Share on other sites

All I can think of is that one or more of your "ereg" fixes were done incorrectly. Various checks the code is looking for are branching the wrong way. That, or you accidentally broke something else in the code when you made changes.

 

I'd rather you pick my mind, rather than my nose.... :)

Link to comment
Share on other sites

Well all is well in the admin so i think i shall restore the catalog files and edit them again and see if it helps.

 

Really hope I can get it sorted otherwise looks like a fresh install with ereg fix first then add the required contribs before restoring the DB....aarrgghh..... (w00t)

Complete Newbie On The Learn - Not A Programmer

But Learning As I Go

Link to comment
Share on other sites

If you're thinking about a "fresh install", bite the bullet and go with osC 2.3.1, which is PHP 5.3 ready. You'll need to transfer over your database, and some contributions/add-ons may be a problem or at least need some recoding. However, you'll be ahead of the game in the long run.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...