Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need some html strip tags help


Peper

Recommended Posts

Posted

I need some help with the following

 

I need to strip html characters from the following output - all the _br / and _p_ and so on

echo ' <meta name="Description" content="' . $header_tags_array['desc'] . '" >' . "\n";

If I put

echo ' <meta name="Description" content="' . strip_tags($header_tags_array['desc']) . '" >' . "\n";

it does nothing

 

Any help please

Getting the Phoenix off the ground

Posted

When you say it does nothing, does it output nothing or does it output the string with HTML tags included?

 

Is your string being escaped prior to being stripped? I'm not sure that strip_tags() will remove HTML character entities.

 

Also, looking at the comments on the strip_tags() manual page, there are some issues with single tags that include a closing slash (e.g., <br />).

Check out Chad's News.

Posted

When you say it does nothing, does it output nothing or does it output the string with HTML tags included?

 

Is your string being escaped prior to being stripped? I'm not sure that strip_tags() will remove HTML character entities.

 

Also, looking at the comments on the strip_tags() manual page, there are some issues with single tags that include a closing slash (e.g., <br />).

Wont believe it, I did look at that page before posting. Not sure

The html is still included on the output - so it must be the wrong one then

 

Which function to use?

Getting the Phoenix off the ground

Posted

If you do the following:

echo "<p>" . $header_tags_array['desc'] . "</p>\n";
echo "<p>" . strip_tags($header_tags_array['desc']) . "</p>\n";

what do you see? Do you get some text including markup for the first, and (hopefully) no HTML tags left in the second? Or does the second show the same as the first? Can you give us an example?

 

What PHP version? Be sure to read the Warnings at http://us.php.net/manual/en/function.strip-tags.php . If your HTML has errors or invalid input, strip_tags() may not work as expected.

Posted

If you do the following:

echo "<p>" . $header_tags_array['desc'] . "</p>\n";
echo "<p>" . strip_tags($header_tags_array['desc']) . "</p>\n";

what do you see? Do you get some text including markup for the first, and (hopefully) no HTML tags left in the second? Or does the second show the same as the first? Can you give us an example?

 

What PHP version? Be sure to read the Warnings at http://us.php.net/manual/en/function.strip-tags.php . If your HTML has errors or invalid input, strip_tags() may not work as expected.

PHP5.2

With both

echo ' <meta name="Description" content="' . $header_tags_array['desc'] . '" >' . "\n";

And

echo ' <meta name="Description" content="' . strip_tags($header_tags_array['desc']) . '" >' . "\n";

I get the same results

Only the description is messed up viewing in page source

<meta name="Description" content="CADDX Alarms - CADDX Networx - GE - _p_Wireless Photoelectric Smoke Detector with Built-In Sounder. Photoelectric smoke sensor with built-in sounder and status LED _br /_
Transmission range 150m (open air) _br /_
Tamper switch _br /_
Sends supervisory signal every 64 minutes_br /_
 _/p_" >

Getting the Phoenix off the ground

Posted

You can safely write <br/> etc. in this forum. It uses BBCode (square brackets) for markup.

 

Assuming your original input actually had HTML tags <p>, <br/> etc., did you have

$header_tags_array['desc'] = "CADDX Alarms - CADDX Networx - GE - <p>Wireless Photoelectric Smoke Detector with Built-In Sounder. Photoelectric smoke sensor with built-in sounder and status LED <br />
Transmission range 150m (open air) <br />
Tamper switch <br />
Sends supervisory signal every 64 minutes<br />
</p>";

? Were there line breaks (newlines) in the string, as shown, or was it one long line? Absolutely nothing is changing when you feed this to strip_tags()? As mentioned before, strip_tags() may have trouble with certain "self-closing" tags, although I would have expected the <p> to be properly removed. I don't know if the line breaks will be removed, or if those will cause problems for a browser if left in. Maybe strip_tags() has trouble because of the embedded line breaks? You may have to remove those first (str_replace "\n" to '' or ' '?).

 

Rather than using strip_tags(), you may just want to do a str_replace() if it's just a small set of tags being used (<p>, <br>) and you know all the variations in use (<br>, <br/>, <br />). Make sure you remove line breaks, too.

Posted

Maybe you have this problem, or something similar.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Maybe you have this problem, or something similar.

 

Yes, thanks that's the one but is not handling the string - still the same output exactly like in the above post without the < >

 

This problem originates from a problem from Header tags

I cannot update the Header tags as I will loose my keywords that was inserted manually when adding a product - no support at that threat for this issue

from file includes/header_tags.php

echo ' <title>' . $header_tags_array['title'] . '</title>' . "\n";
echo ' <meta name="Description" content="' . $header_tags_array['desc'] . '" >' . "\n";
echo ' <meta name="Keywords" content="' . $header_tags_array['keywords'] . '" >' . "\n";

only the description part needs to be sorted out

 

I don't know if anybody else is having the same problem - will be somewhat detrimental to the sites seo

Getting the Phoenix off the ground

Posted

If you can't fix or update it try this.

 

Replace this:

 

echo ' <meta name="Description" content="' . $header_tags_array['desc'] . '" >' . "\n";

 

With this:

 

echo ' <meta name="Description" content="' . str_replace(array("_p_", "_/p_", "_br /_"), "", $header_tags_array['desc']) . '" >' . "\n";

 

Remember the "backup rule" !!!

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Dear Germ, I am writing to try to get your attention to this post, I have just opened the store today, a little panic

 

http://www.oscommerce.com/forums/topic/273598-fatal-error-can-i-erase-this/page__gopid__1515664entry1515664

 

Hi, I have come across the same problem after adding an application

 

Fatal error: Cannot redeclare do_magic_quotes_gpc() (previously declared in /hsphere/local/home/pawlus/nordicjungle.com/catalog/includes/functions/compatibility.php:18) in /hsphere/local/home/pawlus/nordicjungle.com/catalog/includes/functions/compatibility.php on line 18

 

I have trawled through all of the posts surrounding this issue, downloaded Agent Ransack and found that I have 2 sets of files the seem in admin and in catalog, is this the problem otherwise I have searched for repeats with no luck.

 

I would be happy to post the code from any pages

 

please help,

 

Thanks Pawl

Posted

Don't hijack a thread. Start a new one for a different problem.

 

"do_magic_quotes_rpc()" is defined in compatibility.php. There are a separate set of files for the customer side and the admin side -- unless you screwed up something badly with manual editing, they don't get mixed. The compatibility.php file is included once by application_top.php once each in the customer, admin, and installation sides. Since your error message says "line 18" for both, in the same file, I suspect that some code change you've made is including compatibility.php a second time. What changes have you made?

Posted

If you can't fix or update it try this.

 

Replace this:

 

echo ' <meta name="Description" content="' . $header_tags_array['desc'] . '" >' . "\n";

 

With this:

 

echo ' <meta name="Description" content="' . str_replace(array("_p_", "_/p_", "_br /_"), "", $header_tags_array['desc']) . '" >' . "\n";

 

Remember the "backup rule" !!!

Wow, thanks Germ

This really sorted out a big problem

 

You've made my day

echo ' <meta name="Description" content="' . str_replace(array("_p_", "_/p_", "_br /_"), "", $header_tags_array['desc']) . '" >' . "\n";

:thumbsup:

 

Thanks again

Getting the Phoenix off the ground

Archived

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

×
×
  • Create New...