{"id":6724,"date":"2014-04-22T04:40:00","date_gmt":"2014-04-22T04:40:00","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/22\/problem-about-html-entities-collection-of-common-programming-errors\/"},"modified":"2014-04-22T04:40:00","modified_gmt":"2014-04-22T04:40:00","slug":"problem-about-html-entities-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/22\/problem-about-html-entities-collection-of-common-programming-errors\/","title":{"rendered":"problem about html-entities-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1d77d4eb94f1394ff4da699b6f65b743?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMichael Best<br \/>\njavascript html html-entities<br \/>\nThe above screengrab is from Firefox. The cursor is hovering over the yellow spot at the left hand side of the image. It is an &lt;img&gt; element (well actually it&#8217;s an image together with an image map containing a single circular &lt;area&gt; element, but I assume this distinction is unimportant) that has been created and styled in JavaScript, including the application of a title attribute (constructed by cutting and gluing strings). How can I get this to behave and show the intended character<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2a428af3cd0c8c1f7e0c29ea0e2352ed?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFernando Paladini<br \/>\njavascript html-entities html-escape-characters<br \/>\nBefore you ask, I already searched a lot in Stack Overflow and I google it thousand times. Any other case I ever seen here helped me. Let&#8217;s go to my problem:I&#8217;m trying to use the following script in my code:&lt;script type=&#8217;text\/javaScript&#8217;&gt;document.write(&#8220;&lt;script src=&#8217;\/feeds\/posts\/default\/-\/&#8221;+hom_cat1+&#8221;?max-results=1&amp;orderby=published&amp;alt=json-in-script&amp;callback=showhomeposts1&#8242;&gt;&lt;\/script&gt;&#8221;); &lt;\/script&gt;But I&#8217;m using Blogger and it don&#8217;t detect correctly my code (no<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0144ebb7ad7a3fd6cbfe54c95c48ddc9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMark Elliot<br \/>\nphp mysql mysql-real-escape-string html-entities stripslashes<br \/>\nI am trying to input data using forms into the MySQL, and also using mysql_real_escape_string for this purpose. Unfortunately I am having a problem with the output. It displays \\s, or if I use stripslashes then it removes all slashes.If I submit web&#8217;s forms using backslash \\ I get this output:&#8221;web\\&#8217;s forms using backslash \\\\&#8221;See I got a double backslash. But if I use the stripslashes function then it removes all slashes but also removes inputed slash and the output is &#8220;web&#8217;s forms using backslas<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f5ef1b81e1aeb3b921a3034d460ce6af?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkiamlaluno<br \/>\nphp xml xml-parsing html-entities<br \/>\nI am currently running into a problem where an element is coming back from my xml file with a single quote in it. This is causing xml_parse to break it up into multiple chunks, example: Get Wired, You&#8217;re Hired! Is then enterpreted as &#8216;Get Wired, You&#8217; being one object, the single quote being a second, and &#8216;re Hired!&#8217; as a third.What I want to do is:while($data = fread($fp, 4096)){if(!xml_parse($xml_parser, htmlentities($data,ENT_QUOTES), feof($fp))) {break;}}But that keeps breaking. I can run a s<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/769b0e57b44329c34a756e1c2a3bee71?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nToddN<br \/>\nphp html-entities htmlspecialchars<br \/>\nOf course this has been asked before and have searched for solutions, all which have not worked thus far. I want to change out the TM symbol and the ampersand to their html equivelents by using htmlentities or htmlspecialchars:$TEST = &#8220;Kold LockerT &amp; other stuff&#8221;; echo &#8220;ORGINIAL: &#8221; . $TEST . &#8220;&lt;BR\/&gt;&#8221;;echo &#8220;HTML: &#8221; . htmlentities($TEST, ENT_COMPAT, &#8216;UTF-8&#8217;);This displays:ORGINIAL: Kold LockerT &amp; other stuff HTML: I have also tried it with htmlspecialchars and the second parameter ch<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3e486ff0fb305a6fccffe1b3faa30f8f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ncruxi<br \/>\njavascript ruby-on-rails html-entities<br \/>\nI am dealing with Ruby on Rails and JavaScript. The main basic idea is that I create an object in my model&#8217;s class function and call this function in JavaScript. The problem there is that anywhere the HTML entities are encoded. Now in detail: In my model&#8217;s function getData(firstOpt, secondOpt, amount) I create an object that looks as follows (when I call the function in the ruby console): [#&lt;JobCompact build_compact_id: 324&gt;, #&lt;JobCompact build_compact_id: 325&gt;, #&lt;JobCompact buil<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5cfc2067c46749a76a30d2caf963a147?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAverage Joe<br \/>\njavascript xss html-entities<br \/>\n$text = &#8220;( = \\&#8221; &#8216; &amp; \\\\ &lt;\/textarea&gt; : ; . &#8221; ;echo htmlentities($text); \/\/outputs as &#8211;&gt;&gt; ( = &amp;quot; &#8216; &amp;amp; \\ &amp;lt;\/textarea&amp;gt; : ; . \/\/obviously, htmlentities does nothing to ( ) = ; and .htmlentities is a good line of defense but it does not help in javascript contexts. wouldn&#8217;t it be to write your own htmlencode function to further enforce ( ) . ; and = characters to be encoed as well? This way, one function would make you safe across the board. I want t<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/999028eec7943d2e0a6522a9d8400bd2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser453089<br \/>\nphp javascript jquery syntax-error html-entities<br \/>\ni have problem with between php and jQuery\/Javascript&#8230;It wont show up or can&#8217;t work.My Code:if($bottom_1_banner == &#8220;true&#8221;){\/\/$data_AD .= &#8216;$(\\&#8217;.ban_bottom\\&#8217;).html(\\&#8221;.htmlentities($bottom_banner).&#8217;\\&#8217;).text();&#8217;;$data_AD .= &#8216;$(\\&#8217;.ban_bottom\\&#8217;).html(&#8220;&#8216;.htmlspecialchars($bottom_banner).'&#8221;).text();&#8217;; }Error Log: (Chrome\/Safari)&lt;script type=&#8221;text\/javascript&#8221;&gt;$(document).ready(function() {$(&#8216;.ban_bottom&#8217;).html(&#8220;&amp;lt;!&#8211; xxxxxxx &#8211;&amp;gt; ******index.php:11 Uncaught SyntaxError: Unexpected to<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0b647823153e75063dd79d680a396dfb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrkx<br \/>\nphp forms html-entities<br \/>\nI&#8217;m trying to preserve user input in form, which works fine, but if there is no input and I press Submit button I get following error: Notice: Undefined variable: name in C:\\xampp\\htdocs\\syncfolder\\phpsols\\contact_01.php on line 54 value=&#8221;&#8221;&gt; The code I&#8217;m using comes from book &#8220;PHP solutions&#8221;:&lt;?php $errors = array();$missing = array();\/\/check if the form has been submittedif (isset($_POST[&#8216;send&#8217;])){\/\/email processing script$to = &#8216;sampleemail1@gmail.com&#8217;;$subject = &#8216;Mailing script&#8217;;\/\/list o<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5fb005a5415b06c9a771953d9551f76e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFabien Polley<br \/>\nhtml xml html-entities mathml<br \/>\nIn firefox :&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt; &lt;math display=&#8221;block&#8221; xmlns=&#8221;http:\/\/www.w3.org\/1998\/Math\/MathML&#8221;&gt;&lt;mi&gt;&amp;rho;&lt;\/mi&gt; &lt;\/math&gt;results in &#8220;undefined entity&#8221; error.I know there is something missing there. I just don&#8217;t know what I should write to correct the problem. I would like to avoid rewriting every single unicode character into the document.EDIT I tried the following, still not working, same error :&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt; &lt;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/092a6888f9cddacbe2a2b3b463113ef4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nariefbayu<br \/>\nphp escaping html-entities<br \/>\nI have a script like this:document.getElementById(&#8216;debugLayer&#8217;).innerHTML = &#8216;&lt;?php foreach (self::$errorLogs as $item) { echo htmlentities ($item, ENT_QUOTES).'&lt;hr \/&gt;&#8217;; } ?&gt;&#8217;;where $errorLogs is an array of list. But it must have not escape correctly, since firefox say to this:Error: malformed Unicode character escape sequence Source File: X Line: 553, Column: 63 Source Code: document.getElementById(&#8216;debugLayerDIVcontent_10&#8217;).innerHTML = &#8216;&amp;lt;span style=&amp;quot;background-color<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c8db82189117b8df2a25651113586b11?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbryc<br \/>\nhtml html-entities behavior<br \/>\nIn a plain HTML document &amp;pound (dec 163) renders as \u00a3 without needing the ;, whereas &amp;oelig (dec 339) will only render a o with the semicolon. It seems that every html entity with a decimal value under 255 will render without needing the semicolon, both in FireFox and Chrome.What gives?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/aaf77577c3e855ec00c5413c8757eab7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAlan<br \/>\nphp-5.3 html-entities<br \/>\nWe&#8217;re using PHP version 5.3.2 with FastCGI under Lighttpd 1.4.26:$ \/usr\/lib\/cgi-bin\/php5 -v PHP 5.3.2-1ubuntu4.20 with Suhosin-Patch (cgi-fcgi) (built: Jul 15 2013 17:10:44) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologieswith XCache v1.3.0, Copyright (c) 2005-2009, by mOoI&#8217;ve got a php script that&#8217;s generating a notice to the Lighttpd web server error log:2013-08-30 14:11:46: (mod_fastcgi.c.2711) FastCGI-stderr: PHP Notice: Use of undefined c<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1c16b153fa49895083ab294dc3648334?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLukas Knuth<br \/>\nphp xml-parsing html-entities htmlspecialchars<br \/>\nI&#8217;m using XHTML Transitional doctype for displaying content in a browser. But, the content is displayed it is passed through a XML Parser (DOMDocument) for giving final touches before outputting to the browser.I use a custom designed CMS for my website, that allows me to make changes to the site. I have a module that allows me to display HTML scripts on my website in a way similar to WordPress widgets.The problem i am facing right now is that I need to make sure any code provided through this mo<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/619fd20d9e7dc14faccc82c68860e2cd?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAKWF<br \/>\nruby-on-rails ruby gem html-entities<br \/>\nThis has happened before. It goes DIRECTLY AGAINST the gem&#8217;s usage documentation.Even though I do this:require &#8216;htmlentities&#8217;and then THIS:coder = HTMLEntities.newyields the following message:undefined method `new&#8217; for HTMLEntities:ModuleNO! NO NO NO NO NO! HTMLEntities is a CLASS. It is NOT a module.What in the hell is going on here? All of my reports code is broken now!I am using rvm. I scoured my project gem directory and the global gem directory. There is NO other occurrence of HTMLEntities<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3c448146cc10087c31a564800bdb6ca6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nanimuson<br \/>\njavascript escaping html-entities<br \/>\nI have the following:var text = &#8220;\u00dcbergro\u00dfe \u00c4pfel mit W\u00fcrmern&#8221;;I&#8217;m searching for a Javascript function to transform the text so that every special letter is represented by its HTML entity sequence like this:var newText = magicFunction(text); &#8230; newText = &#8220;&amp;Uuml;bergro&amp;szlig;e &amp;Auml;pfel mit W&amp;uuml;rmern&#8221;;The function should not only escape the letters of this example but also all of these.How would you achieve that? Is there any existing function out there? (Plain, because a solu<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4e6875fca5b169e666882616e30bc652?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ncrmpicco<br \/>\nhtml firefox gmail html-entities html4<br \/>\nI am having an issue with the Euro currency sign HTML entity when viewing in GMail.I am using &amp;#0128; instead of &amp;euro; and this shows as a square box\/bad character in GMail when using Firefox, whereas when I switch it to &amp;euro; it works.It doesn&#8217;t seem to affect Yahoo! email accounts, only GMail from what I have seen so far.Some research leads me to believe that &amp;#0128; is less widely supported than &amp;euro; and I should switch, however i&#8217;d ike to know which should be used for<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e21d21977b05208b8d46859659b51290?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nZer0mod<br \/>\nphp html html-entities<br \/>\nSo, I have a basic little script that takes input from an HTML form, is processes by PHP and then writes it to a text file in the form of CSS. I&#8217;ve already got some jerkwad trying to drop tables on the server (There is no SQL but I&#8217;d like to keep people from trying none the less) Here is the code that I have thus far, can someone help me block potentially bad input via htmlentities or something else?The HTML Form &lt;html&gt;&lt;body&gt; &lt;h4&gt;Codes Form&lt;\/h4&gt; &lt;form action=&#8221;codes.php<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fe0bccbdaa4c4db6b1fb398d3c75bc7b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPaolo_Mulder<br \/>\nphp html-entities utf8-decode<br \/>\nPossibly a very simple question , but I was wondering how I can decode utf8 characters into readable characters.For example :L&amp;#x27;heure supr&amp;#xEA;meInto L&#8217;heure supr\u00eameI tried the following :utf8_encode , utf8_decode And `html_entity_decode($string, ENT_COMPAT, &#8220;UTF-8&#8221;);`The output never gave me the correct characters , for example html_entity_decode($string, ENT_COMPAT, &#8220;UTF-8&#8221;); returned L&#8217;heure supr\u00c3\u00aameEDIT : It was a stupid question , html_entity_decode($string, ENT_COMPAT, &#8220;ISO-8<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6b5b0d38e3dc35cae066f90204773393?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlauthiamkok<br \/>\nphp xml special-characters html-entities<br \/>\nWhy does XML display error on certain special characters and some are ok?For instance, below will create error,&lt;?xml version=&#8221;1.0&#8243; standalone=&#8221;yes&#8221;?&gt; &lt;Customers&gt;&lt;Customer&gt;&lt;Name&gt;L&amp;ouml;ic&lt;\/Name&gt;&lt;\/Customer&gt; &lt;\/Customers&gt;but this is ok,&lt;?xml version=&#8221;1.0&#8243; standalone=&#8221;yes&#8221;?&gt; &lt;Customers&gt;&lt;Customer&gt;&lt;Name&gt;&amp;amp;&lt;\/Name&gt;&lt;\/Customer&gt; &lt;\/Customers&gt;I convert the special character through php &#8211; htmlentities(&#8216;L\u00f6ic&#8217;,ENT_QUOT<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/aPAUa.png?s=32&amp;g=1\" \/><br \/>\nPeter Boughton<br \/>\ncoldfusion html-entities<br \/>\nI need a way to transform numeric HTML entities into their plain-text character equivalent. For example, I would like to turn the entity:&amp;#0233;into the character:\u00e9Through some googling around I found a function called HtmlUnEditFormat, but this function only transforms named entities. Is there a way to decode numeric entities in ColdFusion?<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Michael Best javascript html html-entities The above screengrab is from Firefox. The cursor is hovering over the yellow spot at the left hand side of the image. It is an &lt;img&gt; element (well actually it&#8217;s an image together with an image map containing a single circular &lt;area&gt; element, but I assume this distinction is unimportant) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6724","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6724"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6724\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}