That is because you have the type of the parameter set to be a string... and really it is a comma separated list of integers.
To fix the problem, just change the parameter type of the target parameter you have in your query. It should update line 31 to:
$Recordset2->bindParam("il", "".$mids ."", "10"); //target