I am finding the following error: "Warning: htmlspecialchars() expects parameter 1 to be string, array given..."
This happens in the following piece of code and only when I added input fields to the form whose name was an array (so I could repeat the input multiple times). The line the error refers to is ($v=htmlspecialchars($value);)
if ($len > 2) {
$values=array();
$possible=array('orderId','source','date', 'clientPrice','firstName','lastName','email','address','city','zip');
$i=1;
$query2 = "UPDATE orders SET ";
foreach ($_POST as $key => $value) {
$k=htmlspecialchars($key);
$v=htmlspecialchars($value);
if(in_array($k, $possible)) {
$query2 .= $k." = ?";
$values[]=$v; //append values to an array for later use
if($i < ($len-2)) $query2 .= ', ';
$i++;
}
}
}
Any idea of how to solve this and the reason for the error?