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
2
votes
2 answers

Problems with str_split

I'm new here, and I have a question. I'm doing a code that I'll use soon, more something left me with a huge doubt. So I'm separating the word more special characters converted are being separated, I wish they would get together to assign a color to…
2
votes
1 answer

Special characters UTF8 not displaying in Safari

I thought this was something easy to Google, but the answers I found, did not fix my problem In Chrome my RSS feeds are looking like this "¿Qué es un serum antimanchas?" But all the rest characters are ok .. In Safari, is the opposite. This line…
Moncho Chavez
  • 694
  • 2
  • 10
  • 31
2
votes
2 answers

str_replace() or htmlspecialchars() for escaping special characters in
 blocks

Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. That, with the limited knowledge that I have, can be easily done in two different ways in PHP. Like…
its_me
  • 10,998
  • 25
  • 82
  • 130
2
votes
1 answer

PHP - htmlspecialchars and UTF-8

I am just trying to confirm something with htmlspecialchars. I have just converted my database into UTF-8, and I think I finally have it all working, but throughout my code I have used the PHP htmlspecialchars function: htmlspecialchars($val,…
Lizard
  • 43,732
  • 39
  • 106
  • 167
2
votes
3 answers

PHP Escaped special characters to html

I have string that looks like this "v\u00e4lkommen till mig" that I get after doing utf8_encode() on the string. I would like that string to become välkommen till mig where the character \u00e4 = ä = ä How can I achive this in PHP?
AlexanderNajafi
  • 1,631
  • 2
  • 25
  • 39
2
votes
1 answer

PHP: htmlspecialchars() and non-English languages

I'm new to PHP. When I try htmlspecialchars() with ENT_HTML5 flag it works, but all non-English words are removed. I tried: For…
mirelana
  • 94
  • 1
  • 11
2
votes
2 answers

Convert QString to text with substitutes for HTML special characters (e.g. tags)

The user will be able to put in some text into a QLineEdit in a Qt environment. However, these input texts can contain HTML special characters. My aim is to convert this text by replacing all HTML special character occurences with substitutes. A…
Bear
  • 35
  • 2
  • 4
2
votes
2 answers

mysql_real_escape_string, stripslashes and htmlspecialchars

When I post a variable to the database, of course, I use mysql_real_escape_string. This way special characters go in the database as it should. When I read this variable out of the database, I use mysql_real_escape_string again together with…
2
votes
3 answers

Do i need to apply htmlspecialchars / htmlentites on json array?

I wanted to ask that in a php script of mine which I am accessing through an ajax request, I am returning json data ( converted from an array ) as such echo json_encode($row_array); I get this data in jquery and display it in a form. Do i need to…
Imran Omar Bukhsh
  • 7,849
  • 12
  • 59
  • 81
2
votes
2 answers

How to convert html special chars to ordinary HTML?

Possible Duplicate: How to decode HTML entities using jQuery? HtmlSpecialChars equivalent in Javascript? I need to convert with escaped htmlspecialchars to a valid HTML code, for example: <p>Text here</p> should be displayed in the…
Ivan Gromov
  • 4,195
  • 9
  • 41
  • 57
2
votes
1 answer

Do i have to change all my htmlspecialchars ... ENT_QUOTES in mysql_real_escape_string?

i wanted to protect my website from sql injections and other possible risks, so i changed all my sql queries by adding for each variable something like this : $getLid = htmlspecialchars($_GET[lid], ENT_QUOTES); For my 50 files... But i have just…
Paul
  • 6,108
  • 14
  • 72
  • 128
2
votes
1 answer

htmlspecialchars causing text to disapear

I encountered a particular string (it's not completely printable, but you can see it below) that causes a htmlspecialchars() to return a zero-length string. Is there any way this can be fixed? $Stmnt = 'SELECT subject_name FROM bans WHERE id =…
Lakey
  • 1,948
  • 2
  • 17
  • 28
2
votes
2 answers

Twig - use quotation mark as separator for join filter

I pass my template an array of strings which I would like to convert to a jaavascript array: Controller file (php): $myVar = array('a','b','c'); Desired html: var myVar = ["a","b","c"]; I try the following code (twig): var myVar = ["{{ myVar |…
guyaloni
  • 4,972
  • 5
  • 52
  • 92
2
votes
4 answers

using htmlspecialchars in value attribute of text input

My question is similar to this question but I'm not using code igniter. I'm echoing variables obtained from a database into the value attribute of a text input. The variables may contain ' or " or any other special chars. I tried:
Devin Crossman
  • 7,454
  • 11
  • 64
  • 102
2
votes
2 answers

Should i sanitize/filter user input and output when using PHP PDO?

I am using PDO to users input, but right now I'm not using PDO when displaying content from my MySQL database (still the old fashioned way with SQL commands..). Is it necessary to filter/sanitiza inputs from users when inserting data to a MySQL…
2by
  • 1,083
  • 5
  • 22
  • 39