I have some strange observation with mysql_real_escape_string
.
when trying this code on a localhost WAMP server, I am getting:
mysql_real_escape_string() expects parameter 1 to be string, array given
The code is like this:
$_POST= array (
'level_id' => '4',
'initLevel' => '4',
'subject_ids' =>
array (
0 => '6',
),
'category' => '11',
'areas' => '-1',
'dist_code' => '',
'district' => '',
'gender_preference' => '2',
'race' =>
array (
0 => '1',
1 => '2',
),
'with_photo' => '0',
'min_age' => '',
'max_age' => '',
'notification' => '1',
'ban_tutor' => '',
'sort_by' => 'regi_date',
'fromdate' => '',
'day' => '14',
'month' => '5',
'year' => '2017',
'todate' => '2017-06-14',
'result_page' => '10',
'search' => 'Search Tutors',
);
$_POST = array_map('mysql_real_escape_string', $_POST);
echo '<pre>' . var_export($_GET, true) . '</pre>';exit;
but when I am trying the same on the live server. I am not getting any error, but the result is stripped the array values like this:
array (
'level_id' => '4',
'initLevel' => '4',
'subject_ids' => NULL,
'category' => '11',
'dist_code' => '',
'district' => '',
'gender_preference' => '2',
'race' => NULL,
'with_photo' => '0',
'min_age' => '',
'max_age' => '',
'notification' => '1',
'ban_tutor' => '',
'sort_by' => 'regi_date',
'fromdate' => '',
'day' => '14',
'month' => '5',
'year' => '2017',
'todate' => '2017-06-14',
'result_page' => '10',
'search' => 'Search Tutors',
)
Need some direction, how to use it correctly.
Note: I know mysql_real_escape-string
is deprecated and PDO is the the appropriate solution. I am just working on my client's server. The changing the complete system immediately is not feasible.