Questions tagged [htmlspecialchars]

htmlspecialchars is a PHP function that convert special characters to HTML entities.

htmlspecialchars is a PHP function that convert special characters to HTML entities.

Famous question: htmlentities() vs. htmlspecialchars()

467 questions
4
votes
5 answers

html special symbols is displayed as characters

I've been trying to set content of a text input dynamically using JS, the problem I encountered is I can not have the browser render the special symbols rather than chars so for example document.getElementById("textField").value = "nbsp"; Instead…
user1935724
  • 554
  • 1
  • 6
  • 18
4
votes
2 answers

Removing Special character when importing data from excel

I'm importing data from excel to data table. It's working fine. But in some fields, data imported with unknown character '�'. But excel doesn't have such character. Here is my code. I have tried in many ways. This is my final code. $new_prod_desc…
Devpower
  • 43
  • 2
  • 6
4
votes
1 answer

RSS Feed & Special Characters

I have been working for hours on trying to get a rss feed. The problem is with special characters. I have data listed as a list on the website, but I want a rss feed also. The title has "&" which are written as $amp;. If I use htmlspecialchars it…
Elliott
  • 186
  • 1
  • 3
  • 10
4
votes
3 answers

htmlentities and htmlspecialchars refuse to process string

Since the last update to PHP5 5.4.0-3 on my Debian box I noticed that some pages have empty fields where text from the MySQL database should be. I played around a bit and found the problem.
Christian
  • 582
  • 9
  • 21
3
votes
2 answers

convert html characters back to text in Flash - AS3

I need to generate an editable xml file to supply content to a flash website. I am generating my file with a html form, and htmlspecialchars e.g.: $currentItem = htmlspecialchars(stripslashes($currentItem)); This is to prevent xml entries…
jsims281
  • 2,206
  • 2
  • 30
  • 57
3
votes
1 answer

Why is there no $encoding parameter in htmlspecialchars_decode()?

If we check out the documentation of the htmlspecialchars() function in PHP, we see that it has an $encoding parameter to specify the encoding of the input string. Now, conversely, I expect the opposite htmlspecialchars_decode() function to also…
coderboy
  • 1,710
  • 1
  • 6
  • 16
3
votes
1 answer

What is a function that will allow output with HTML and avoid XSS attacks

I am looking for a way or function that will allow me to display data from my mySQL database. The users are allowed to post articles, that I use mysql_real_escape_string to avoid SQL injections before inserting their post in the DB. For my testing…
EnexoOnoma
  • 8,454
  • 18
  • 94
  • 179
3
votes
1 answer

htmlspecialchars not working as expected

I am probably using it wrong, the problem is this: I have php code that gets echoed to the page like so: " . htmlspecialchars($array['text']) . "" ?> That variable gets echoed from the databse in an html structure like this…
Operter
  • 95
  • 7
3
votes
2 answers

php XML DOM translates special chars to &#xYY;

I send this with AJAX POST:
  • 3
    votes
    6 answers

    Insert single quote or double quote to the database with codeigntier

    When I load the data into the input box: if the data contain single quote, it will strip the later part of the string, because of the conflict of the symbol So I…
    user782104
    • 13,233
    • 55
    • 172
    • 312
    3
    votes
    2 answers

    What is difference between FILTER_SANITIZE_FULL_SPECIAL_CHARS and htmlspecialchars?

    I have a textarea which will be available to users as comment box so any sort of inputs are acceptable but that should be accepted only as text and not code. Basically I want to protect my database. I don't want to strip tags or such thing, I just…
    bɪˈɡɪnə
    • 1,087
    • 2
    • 23
    • 46
    3
    votes
    1 answer

    php urlencode and htmlspecialchars a variable inside started function within html

    I have the function: function after_char($char, $var) { $get = explode($char, $var); $text= $get[1]; echo $text; } I have the html link: Potwierdź…
    3
    votes
    2 answers

    Display HTML special characters stored in JavaScript string

    I need to dynamically append a text to a
    with JavaScript. This text is retrieved from a database and it also contains special character as ü or '. Now i'm using the createTextNode() but the HTML special characters like &xxxx; aren't "resolved"…
    Michele
    • 149
    • 1
    • 10
    3
    votes
    3 answers

    How to use substring on non english characters?

    i have small site where i display search results of posts titles, some titles are up to 255 characters long and while displaying those in html table , the table's row breaks i.e. doesnt shows correct so i use substr php function to trim the title…
    user1642018
    3
    votes
    1 answer

    replace all but certain html tags with htmlspecialchars() in PHP?

    I would like to process my user input to allow only certain html tags, and replace the other ones by their html entities, as well as replace non-tag-characters. For example, if I only wanted to allow the and the tag, then allow_only("This…
    user1111929
    • 6,050
    • 9
    • 43
    • 73