-1

i know that on stack, exists a lot of questions related to this.. but i didnt found my answer

Im trying to create a function that returns an array of POST values. and i'm getting error on an array map:

function clean_the_data ($data) {
    if ( is_array($data) ) {
        $data = array_map("trim", $data);
        if (get_magic_quotes_gpc()) { $data = array_map("stripslashes", $data); }


        $data = array_map($data, array($this->mysqli(), 'real_escape_string'));
    }else{
        $data = trim($data);
        $data = stripslashes($data); 

        $data=  $this->mysqli->real_escape_string($data);

    }
    return $data;
}

In the line

$data = array_map($data, array($this->mysqli(), 'real_escape_string'));

Im not getting this...

thanks for your time

  • Honestly, most of this code is utterly pointless/useless. You're coding to handle PHP configurations and versions that are don't even qualify as "stone age". Don't try to compensate for magic quotes - anyone still running a magic-quotes enabled PHP version deserves all the pain they're suffering. And blindly sql-escaping everything without any sense of HOW the data is going to be used is also pointless. – Marc B Sep 22 '14 at 21:12
  • Thanks for your answer.. But the main objective of this, is change the all function... And a tip would be better. But, thanks anyway – user3587262 Sep 22 '14 at 22:23

1 Answers1

-2

I found this on PHP website: http://php.net/manual/en/pdo.prepared-statements.php

I'm doing prepared statements, is it more secure ?

Also, I updated my function to:

function clean_the_data ($data) {
    if ( is_array($data) ) {
        $data = array_map($data, array($this->mysqli(), 'real_escape_string'));
    }else{
        $data=  $this->mysqli->real_escape_string($data);
    }
    return $data;
}
Sheepy
  • 17,324
  • 4
  • 45
  • 69