htmlspecialchars and escaping with datatables
htmlspecialchars and escaping with datatables
Hi Guys
I have a server processed table and i'd like to improve the security. I use htmlspecialchars and have tried to implement it within the server processing php script. whatever i try though, i'm getting parse errors.
Does anyone have any ideas?
[code]
while ( $aRow = mysql_fetch_array( $result ) )
{
$row = array();
$row['DT_RowId'] = 'row_'.$aRow[$sIndexColumn]; //'id replaced with index column LW
//Add Specific Classes for certain tables
if ($_SESSION['tablephpid']=='enquiry' ) {
$row['DT_RowClass'] = $aRow['result'];
}
for ( $i=0 ; $i
I have a server processed table and i'd like to improve the security. I use htmlspecialchars and have tried to implement it within the server processing php script. whatever i try though, i'm getting parse errors.
Does anyone have any ideas?
[code]
while ( $aRow = mysql_fetch_array( $result ) )
{
$row = array();
$row['DT_RowId'] = 'row_'.$aRow[$sIndexColumn]; //'id replaced with index column LW
//Add Specific Classes for certain tables
if ($_SESSION['tablephpid']=='enquiry' ) {
$row['DT_RowClass'] = $aRow['result'];
}
for ( $i=0 ; $i
This discussion has been closed.
Replies
How?
And what are the precise "parse errors" you're getting?
[code]htmlspecialchars($json_encode($output), ENT_QUOTES, 'UTF-8');[/code]
JSON data from server could not be parsed. this is caused by a JSON formatting error
echo htmlspecialchars(json_encode($output), ENT_QUOTES, 'UTF-8');
You need to encode each individual component. In the general output line for that code for example.
Allan
Incidentally if you're just pulling data from a database htmlspecialchars doesn't have much relevance to security.
i think this is probably a lack of knowledge on my part.. basically, i wanted to stop the user from being able to utilise html within the fields. Ie. if they save a name with bob..
at the moment, this will show the field in bold within the table. i could stop the user from entering < or > but thought i could do this when processing the php ?
This link shows examples:
http://www.hawkee.com/snippet/8641/