midgley Posted June 12, 2011 Share Posted June 12, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/239148-please-help-before-i-gauge-my-eyes-out-with-rusty-spoons/ Share on other sites More sharing options...
fugix Posted June 12, 2011 Share Posted June 12, 2011 Firstly, I normally don't ask this since it's not my place. Bit can you please wrap you code in the code tags provided. I want to gouge my eyes out with spoons just trying to read your code. Quote Link to comment https://forums.phpfreaks.com/topic/239148-please-help-before-i-gauge-my-eyes-out-with-rusty-spoons/#findComment-1228691 Share on other sites More sharing options...
xyph Posted June 12, 2011 Share Posted June 12, 2011 Echo $description and make sure it is what you'd expect. Make sure the > and < aren't > or < Quote Link to comment https://forums.phpfreaks.com/topic/239148-please-help-before-i-gauge-my-eyes-out-with-rusty-spoons/#findComment-1228693 Share on other sites More sharing options...
midgley Posted June 12, 2011 Author Share Posted June 12, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/239148-please-help-before-i-gauge-my-eyes-out-with-rusty-spoons/#findComment-1228699 Share on other sites More sharing options...
mikesta707 Posted June 12, 2011 Share Posted June 12, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/239148-please-help-before-i-gauge-my-eyes-out-with-rusty-spoons/#findComment-1228701 Share on other sites More sharing options...
xyph Posted June 12, 2011 Share Posted June 12, 2011 <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? Quote Link to comment https://forums.phpfreaks.com/topic/239148-please-help-before-i-gauge-my-eyes-out-with-rusty-spoons/#findComment-1228702 Share on other sites More sharing options...
midgley Posted June 12, 2011 Author Share Posted June 12, 2011 no, i have no eyes but i hear what your saying and thanks for the help, much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/239148-please-help-before-i-gauge-my-eyes-out-with-rusty-spoons/#findComment-1228712 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.