I receive the following warning notice when passing an array from the HTML to the PHP:
Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in (.../post2.php on line 68)
Here's where the data are captured in the input2.php file:
<td>
<select name="adult_fn_list[]" size="3" multiple="multiple">
<?php
$adult_sql = "SELECT first_name FROM member
WHERE family_fkey = 34
AND member_type = 'Adult'
ORDER BY prim_key";
$res=mysqli_query($link, $adult_sql) or die (mysqli_error($link));
while($row=mysqli_fetch_assoc($res))
echo"<option value=".$row['first_name'].">".$row['first_name']."</option>";
?>
</select>
</td>
Here's line 68 in the post2.php code
$adult_fn_list = mysqli_real_escape_string($link, $_POST[adult_fn_list]);
I don't know why I'm receiving the warning notice. When I print the array and elements out, they appear fine. The following code:
print "The value of the adult_fn_list is: ";
print_r($_POST['adult_fn_list']);
print "<br /><br />The value of each individual element is: <br />";
Foreach ( $_POST['adult_fn_list'] as $SelectedFN )
print ($SelectedFN . "<br />");
exit;
Produces the following results:
The value of the adult_fn_list is: Array ( [0] => Leonard [1] => Julia )
The value of each individual element is:
Leonard
Julia