Jump to content

Recommended Posts

i simply cannot get strip_tags to work when i fetch a result back from mysql

 

my code:

while($fetch = mysql_fetch_array($queryProduct))

{

                $description = ($fetch['description']);

$descriptionTagged = strip_tags($description);

echo("1".$descriptionTagged)."<br/><br/>"; // strips nothing

}

 

                //test code

$description2 = '<p> <strong>Specification:</strong> Our <em>HP CE505A (05A) </em>replacement toner cartridges provide an affordable alternative to original toner cartridges<span style="font-style: italic;">. </span>Our <strong>HP CE505A (05A) </strong>toner cartidges are manufactured to the highest standard and are guaranteed to match or exceed the original equipment manufactures (OEM) capacity for a fraction of the cost. <span style="font-family: arial,helvetica,sans-serif;">Buy with confidence, all our compatible ink cartridges use the very <strong>latest chip technology</strong> and carry a <strong>3 year shelf life</strong> promise, plus for that extra piece of mind we have included a no quibble <strong>100% money back guarantee</strong> on all our replacement toner cartridges.</span><br /> <br /> At Cartridgebeach we put our customers first, this is why we only stock <em>replacement </em>laser toner, ensuring that you consistently receive the highest quality product possible. Do you know the difference between replacement and remanufactured toner cartridges? <a href="http://www.cartridgebeach.co.uk/compatible_vs_remanufactured_toner">Click Here</a> to find out.</p> <h2 style="font-weight:normal;"> <span style="font-size:12px;"><span style="font-family: arial,helvetica,sans-serif;"><strong>Includes:</strong> Black - HP CE505A (05A)<br /> </span></span></h2> <p class="MsoNormal" style=""> <span style="font-size:12px;"><span style="font-family: arial,helvetica,sans-serif;"><strong>Compatible with: </strong>LaserJet P2035, LaserJet P2035N, LaserJet P2050, LaserJet P2055, LaserJet P2055d, LaserJet P2055dn, LaserJet P2055x, Laserjet P2030</span></span></p>';

$descriptionTagged2 = strip_tags($description2);

echo("2".$descriptionTagged2."<br/><br/>"); // strips successfully

 

can somebody please point out what im doing so wrong here?

while($fetch = mysql_fetch_array($queryProduct))
   {
                $description = ($fetch['description']);
      $descriptionTagged = strip_tags($description);
      echo("1".$descriptionTagged)."<br/><br/>"; // strips nothing
   }

                //test code
      $description2 = '<p> <strong>Specification:</strong> Our <em>HP CE505A (05A) </em>replacement toner cartridges provide an affordable alternative to original toner cartridges<span style="font-style: italic;">. </span>Our <strong>HP CE505A (05A) </strong>toner cartidges are manufactured to the highest standard and are guaranteed to match or exceed the original equipment manufactures (OEM) capacity for a fraction of the cost. <span style="font-family: arial,helvetica,sans-serif;">Buy with confidence, all our compatible ink cartridges use the very <strong>latest chip technology</strong> and carry a <strong>3 year shelf life</strong> promise, plus for that extra piece of mind we have included a no quibble <strong>100% money back guarantee</strong> on all our replacement toner cartridges.</span><br /> <br /> At Cartridgebeach we put our customers first, this is why we only stock <em>replacement </em>laser toner, ensuring that you consistently receive the highest quality product possible. Do you know the difference between replacement and remanufactured toner cartridges? <a href="http://www.cartridgebeach.co.uk/compatible_vs_remanufactured_toner">Click Here</a> to find out.</p> <h2 style="font-weight:normal;"> <span style="font-size:12px;"><span style="font-family: arial,helvetica,sans-serif;"><strong>Includes:</strong> Black - HP CE505A (05A)<br /> </span></span></h2> <p class="MsoNormal" style=""> <span style="font-size:12px;"><span style="font-family: arial,helvetica,sans-serif;"><strong>Compatible with: </strong>LaserJet P2035, LaserJet P2035N, LaserJet P2050, LaserJet P2055, LaserJet P2055d, LaserJet P2055dn, LaserJet P2055x, Laserjet P2030</span></span></p>';
      $descriptionTagged2 = strip_tags($description2);
      echo("2".$descriptionTagged2."<br/><br/>"); // strips successfully

 

visit the site http://www.cartridgebeach.co.uk/testArea/shopzillaFeed/generateFeed.php to see what the results of the two echos are.

looks like the field you get from your database doesn't have actual HTML but html entities. If you want to change these entities back into valid HTML, you can use html_entity_decode(): http://php.net/manual/en/function.html-entity-decode.php

 

Once you decode the html entities, then you can strip the tags. Though, to be honest, you are probably using html entities when you store the data into your database, and you may want to change the script at that end.

<strong>Specification:</strong> Our <em>HP CE505A (05A) </em>replacement toner cartridges provide an affordable alternative to original toner cartridges<span style="font-style: italic;">

 

Do you see the issue yet?

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.