Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:07:24+00:00 2026-05-31T11:07:24+00:00

Here is my function that i created for escape strings… function clean_array($value) { foreach($value

  • 0

Here is my function that i created for escape strings…

function clean_array($value)

{

      foreach($value as $key => $val)

    {
    if(get_magic_quotes_gpc())
        {
        $value[$key]=stripslashes($val);
        }
    $value[$key]= mysql_real_escape_string($val);
    $value[$key]=htmlentities($val);
    $value[$key]=htmlspecialchars($val);
    }

return $value;
unset($val);

}

Please explain step by step bcoz i am beginner in PHP.I am very grateful to u if you give solution…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:07:25+00:00Added an answer on May 31, 2026 at 11:07 am

    Your code is accomplshing absolutely nothing. Before you start worrying about writing “secure” code, you should learn basic coding. Walk before you try to run off a cliff.

    1) magic_quotes has been deprecated for a LONG time, and has actually been removed from the latest PHP version. Writing in handlers for it as you are only helps to keep old/obsolete/insecure PHP versions alive.

    2) You continually take $val, do something to it, then store the resulting new data into a variable. But you ALWAYS use the SAME source, and the SAME destination. So your mysql_real_escape_string is destroyed/overwritten by the htmlentities() call, which in turn is destroyed/overwritten by the htmlspecialchars() call. In effect, that entire chunk of code has the operational functionality of:

    foreach ($values as $val => $key) {
        $values[$key] = htmlentities($val);
    }
    

    3) Don’t do an all-in-one security function. Sanitizing/securing data depends ENTIRELY on how you’re going to be using that “secured” data. There is absoulutely ZERO point in doing html transformations on data that will be stored in a database. Likewise, if you are never going to be allowing these “secured” values into a database, then there is no point in doing SQL escaping on them. All you’re doing is performing a sequence of operations that most likely will simply have to be undone again later on, because you weren’t targetting whatever environment that data was going to used for.

    It’s a lot like putting on a rain coat, a parka, a sleeping bag, and a scuba diving rig,BEFORE deciding on whether you’re going outside or for a swim, or if it’s winter out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a function here that is meant to look through a list of
Here is a simple function that converts a string to an integer. int str2int(char
Here is an (artificial) example of using a function that returns an anonymous struct
Here is what I'm trying to do: - i need a function that when
Here's the story... I have a jQuery function that does something, this function is
Someone posted a great little function here the other day that separated the full
We have system here that uses Java JNI to call a function in a
Here is the situation. I have some javascript that looks like this: function onSubmit()
I often hear around here from test driven development people that having a function
All, I THINK that I'm looking for a function for Trilinear interpolation. Here's the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.