I am getting an array to string conversion error when I am trying to run a PDO execute. The execute has to inputs one being a normal string and the other an array. Heres my code:
$id = "1";
$array = array("a", "b", "c");
$in = str_repeat('?,', count($array) - 1) . '?';
$sql1 = "SELECT * FROM tbl1 AS tb1 RIGHT JOIN tbl2 AS tb2 ON (tb1.e_id = tb2.e_id)LEFT JOIN tbl3 AS tb3 ON (tb2.m_id = tb3.m_id) WHERE tb1.u_id = ? AND tb1.letters IN ($in)";
$statement1 = $db_handle->prepare($sql1);
$statement1->setFetchMode(PDO::FETCH_ASSOC);
$statement1->execute(array($id,$array));
$res = $statement1->fetchAll();
So the execute line gives me the string conversion error. I have printed my array and the question marks and they output fine. The sql statement is also fine, I have tried it on phpMyAdmin and it works just fine so clearly I am not using the execute properly but I am not sure how to change the way I have executed it.
Can someone explain it to me?