Web lists-archives.com

Re: [PHP] Array to string conversion error help needed




On Tue, 8 Mar 2016 at 18:56 dealtek@xxxxxxxxx <dealtek@xxxxxxxxx> wrote:

> newbie mysql select help needed.
>
>
> this works fine...
>
> $sth = $pdo->prepare("SELECT * FROM table1 where id IN (1,2,3)"
>
>
>
> but with an array like...
>
> $mylist = array("1","2","3");
> or
> $mylist = array(1,2,3);
>
> these fail...
> $sth = $pdo->prepare("SELECT * FROM table1 where id IN $mylist"
> or
> $sth = $pdo->prepare("SELECT * FROM table1 where id IN ($mylist)"
>
>
> I get error : Array to string conversion...
>
> Q: Can anyone help me fix this?
>

Look at http://php.net/implode

-Stuart