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; 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.