Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Some help updating code for php upgrade. preg_replace_callback


Rachael w.

Recommended Posts

I need some help to get this code right for an error I am getting. It's in an rss feed. Here is the error:

 

 

PHP Warning:  preg_replace_callback(): Requires argument 2, 'Array', to be a valid callback in rss.php on line 112

 

And here is the code:

function strip_html_tags($str) {
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.

	$search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
					 "'<[/!]*?[^<>]*?>'si",          // Strip out HTML tags
					 //"'([rn])[s]+'",                // Strip out white space
					 "'&(quot|#34);'i",                // Replace HTML entities
					 // "'&(amp|#38);'i",
					 "'&(lt|#60);'i",
					 "'&(gt|#62);'i",
					 "'&(nbsp|#160);'i",
					 "'&(iexcl|#161);'i",
					 "'&(cent|#162);'i",
					 "'&(pound|#163);'i",
					 "'&(copy|#169);'i",
					 "'(d+);'e");                    // evaluate as php
	
	$replace = array ("",
					 "",
					 //"\1",
					 "\"",
					 "&",
					 "<",
					 ">",
					 " ",
					 chr(160),
					 chr(161),
					 chr(162),
					 chr(163),
					 chr(169),
					 "chr(\1)");
	
	return preg_replace_callback($search, $replace, $str);
}

That last line above the } is line 112 which is returning the error. I've searched all day to try to figure this out and everything I've tried didn't work. Can anyone help me with this one?

Link to comment
Share on other sites

I can see a mismatch in the number of elements in $search and $replace. Either remove the // against the &amp in $search, or add // against "&" in $replace. You also have an extra " " element in $replace, between &gt and &nbsp.

Link to comment
Share on other sites

I just uninstalled it. I think I was so outdated it wasn't helping much anyway.

 

 

But... while I have your attention could I hit you up for assistance in another matter?

 

I am having an issue where the shipping is not being included in the order total in checkout_confirmation.php. The order total seems to be working properly. If I put it in the cart it shows the subtotal, tax, shipping and total just as it should. The checkout_shipping has the correct rate. So, as you move through checkout everything is fine. Once you hit the confirmation the shipping disappears. Orders are placed with no shipping included.

 

I am using a table rate, haven't changed any of that in any way.

 

Thank you for helping me out. I spent hours trying to figure this out with no luck.

Link to comment
Share on other sites

Yes, I upgraded the server to php 5.6. I've been going through the pages. Most of my issues were with the post, get, cookie and ereg's. I think I've found them all. I have been watching the error reports and no errors are coming up for that page. 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...