kyushudan Posted February 8, 2009 Share Posted February 8, 2009 This text(HTML) resides in a field in a MYSQL dbase: <img src="map_pix/Akashi.jpg" width="200px" height="100px" alt="Akashi Castle"> I fetch it then echo it thus: echo $row['image']. "<br />"; The rendered HTML (as it appears in Firefox 3.0): <img src="map_pix/Akashi.jpg" width="200px" height="100px" alt="Akashi Castle"> I check the source, it reads: <img src="map_pix/Akashi.jpg" width="200px" height="100px" alt="Akashi Castle"> I can see why but How do I make it executable code? ??? ? Even more confusing is that: <img src="map_pix/Akashi.jpg" width="200px" height="100px" alt="Akashi Castle"> works fine when convert the MYSQL contents into an XML file that is read by a google map. But hey, that's not the problem. Apologies if I've posted in the wrong place; php? mysql? html? wasn't sure Link to comment https://forums.phpfreaks.com/topic/144344-solved-echoing-a-variable-with-html-inside-resulting-in-losing-my-mind/ Share on other sites More sharing options...
gevans Posted February 8, 2009 Share Posted February 8, 2009 It looks like you#re using htmlspecialchars() before adding to the database, you can reverse this using htmlspecialchars_decode() htmlspecialchars_decode Link to comment https://forums.phpfreaks.com/topic/144344-solved-echoing-a-variable-with-html-inside-resulting-in-losing-my-mind/#findComment-757418 Share on other sites More sharing options...
kyushudan Posted February 8, 2009 Author Share Posted February 8, 2009 Thank you - A lot!! This did it: echo html_entity_decode($row['image']). "<br />"; Link to comment https://forums.phpfreaks.com/topic/144344-solved-echoing-a-variable-with-html-inside-resulting-in-losing-my-mind/#findComment-757428 Share on other sites More sharing options...
gevans Posted February 8, 2009 Share Posted February 8, 2009 Just remember if users are adding this they can add any html content to your page, as well as javascript Link to comment https://forums.phpfreaks.com/topic/144344-solved-echoing-a-variable-with-html-inside-resulting-in-losing-my-mind/#findComment-757430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.