I'm making a site with PHP-MySQL that allows users to input text into a database, and displays it on various pages.
I know of the htmlspecialchars function, but I am not completely sure about how to use it. Most of my pages query the database for about 10 fields of information from the DB, and as far as I can tell, I will need to put htmlspecialchars before each of those queries. Is there an easier way to block HTML on a page? Is it possible to loop a htmlspecialchars so that it applies to several instances of code on one page?
I've tried:
$query = @mysql_query("SELECT * FROM table");
$row1 = mysql_fetch_array($query);
$row2 = htmlspecialchars($row1);
echo "$row2[fieldname]";
but get a "htmlspecialchars() expects parameter 1 to be string, array given in path\to\site\htdocs\index.php" error message.