I have this php code for html form
if(isset($_POST['job_title'])){
foreach($_POST['job_title'] as $selected) {
$job_title[] = $selected ;
}
$job_title = json_encode($job_title);
$job_title = clean_string($job_title);
}
and the this is what clean_string
function code which cleans input for SQL
function clean_string($string){
global $connection;
$string = trim($string);
$string = stripslashes($string);
$string = htmlspecialchars($string);
$string = htmlentities($string);
$string = mysqli_real_escape_string($connection,$string);
return $string;
}
So when this code execute it cause an error like( expects parameter 1 to be string, array given)
How to solve this problem ? Thanks in advance