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

PHP htmlspecialchars error

why would this $trader_details = array_walk($trader_details, 'htmlspecialchars'); give this error? Severity: Warning Message: htmlspecialchars() expects parameter 2 to be long, string given afaik htmlspecialchars only has optional parameters apart…
stef
  • 26,771
  • 31
  • 105
  • 143
3
votes
1 answer

RSS feed: htmlspecialchars() vs. CDATA

i've written a little class in PHP to generate a simple RSS feed. The item description should also be able to contain html tags. I've wondered which one is the better way and what are the advantages/disadvantages of each method: $item .=…
casper
  • 821
  • 1
  • 8
  • 19
3
votes
1 answer

How to use HTML content in Android listview....?

I am developing an app where i need to use some maths special characters in it. After a long search in google i found the following solution i.e.., How to put some special math symbols in TextView, EditView or other Android UI element. As per the…
code_finder
  • 1,370
  • 2
  • 21
  • 39
2
votes
3 answers

Sanitizing PHP/SQL $_POST, $_GET, etc...?

Ok, this subject is a hotbed I understand that. I also understand that this situation is dependent on what you are using as code. I have three situations that need to be resolved. I have a form in where we need to allow people to make comments…
Matt Ridge
  • 3,633
  • 16
  • 45
  • 63
2
votes
4 answers

Question on preventing SQL with magic_quotes off and XSS with htmlentities

On my server I have magic_quotes turned off. When a user save content as article in my DB from a form, I use $text = mysql_real_escape_string($_POST['text']); to prevent SQL Injecion. This is my input and this is what…
EnexoOnoma
  • 8,454
  • 18
  • 94
  • 179
2
votes
1 answer

Flex & PHP: How to Use htmlspecialchars?

I'm using Flex 3 with remoting to return data from a MySQL database. Do I need to use htmlspecialchars in order to keep my site secure? As I understand it, htmlspecialchars is used to "sanitize" data returned from the db. For example: $query =…
Laxmidi
  • 2,650
  • 12
  • 49
  • 81
2
votes
1 answer

Laravel htmlspecialchars() error when sending email

I'm trying to get emails to send via Sendgrid in Laravel. I've been following Sendgrid's Knowledge Base Article on Sending Email with Laravel I have everything set up in my .env file (though I had to also update the MAIL_HOST in ~/config/mail.php)…
Ryan Dorn
  • 679
  • 2
  • 8
  • 20
2
votes
3 answers

help to get rid of HTML special chars in database

I've migrated my site from interspire CMS to Joomla! CMS. I've managed to migrate all the database of articles, but some of them have a weird issue - when I access the page from joomla, the title contains HTML entities like ’. As you can…
Yanipandos
  • 21
  • 1
  • 3
2
votes
3 answers

Best Practices when outputting html data from database to browser

I store html data in a database. The html data is very simple, and is generated by a wysiwyg editor. Before I store the html data in the database and I run it through HTMLPurifier, to remove any badness. When I output data back out to the browser,…
2
votes
2 answers

Sanitize content outside of [code] tags with one filter and content inside [code] tags with another filter

I'm trying to sanitize comments on my page, but I only want to remove html tags etc. from content outside the [code] [/code] tags. As for content inside the tags, I only want to use htmlspecialchars($data, ENT_QUOTES, 'UTF-8'); on. So if I have a…
Rajohan
  • 1,411
  • 2
  • 10
  • 27
2
votes
1 answer

Encoding Issue Title Tag

I've got a little problem with the tag in combination with PHP. My code is: $title = '....'; echo ''.htmlspecialchars($title).''; When i use "Niederländische Zitate" the browser outputs "Niederl�ndische Zitate" When i use…
Simon
  • 5,464
  • 6
  • 49
  • 85
2
votes
2 answers

How to allow & symbol when using htmlspecialchars()

I am using htmlspecialchars() on my site to display status post from users. The status post is being saved to my database and pulled to show in their timeline. I'm using laravel 5.3 The problem is if someone post something like: Netflix & Chill,…
Luna
  • 537
  • 1
  • 12
  • 26
2
votes
1 answer

htmlspecialchars() vs htmlpurifier library

What are the differences between the built-in php method htmlspecialchars() and htmlpurifier library?
Raja
  • 197
  • 3
  • 14
2
votes
2 answers

how to display htmlspecialchars in PHP

How would I make this actually display EXACTLY with PHP? $answer= echo "The function is: htmlspecialchars ($answer)."
2
votes
1 answer

htmlspecialchars() is causing a variable to return blank data?

I am pulling data from a database using mysqli and PHP. This works OK but I get a random character (black question mark) replacing apostrophes in words, so I thought I could use the htmlspecialchars() function to have them display properly, but it…
BBLJ84
  • 175
  • 1
  • 12