Jump to content

Sanatising Arrays and Single elements with one function


kmaid

Recommended Posts

Hi guys,

 

I am trying to improve my sanatizing function to allow me to send single elements and arrays to be sanatised however i am running into issues. The stripslashes function does not appear to be working as when i put a string like "Test\" it comes out with "Test\\".

 

 

        $input_arr = array();
        foreach ($Data as $key => $input_arr)
        {
		$Data[$key] = stripslashes($Data[$key]);
		$Data[$key] = htmlentities($Data[$key]);
		$Data[$key] = mysql_real_escape_string($Data[$key]); 
        }
	return $Data; 

That is most of the function however i cut off the top :x

 

    function libStripInputSlashes($Data)
    {
        $input_arr = array();
        foreach ($Data as $key => $input_arr)
        {
		$Data[$key] = stripslashes($Data[$key]);
		$Data[$key] = htmlentities($Data[$key]);
		$Data[$key] = mysql_real_escape_string($Data[$key]); 
        }
	return $Data; 
    }

 

I am afraid i dont remember why i put that in i wrote this code a while ago only to deal with $_POST and $_GET but have since needed more from it. I worked from http://uk3.php.net/foreach and have been playing with it for a bit my original idea was to temporarily store the variables in $input_arr and then save them back into the original array. However I have been staring at this code for a bit and it seems to make less and less sense

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.