RE: Array to string conversion error help needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!
> $sth = $pdo->prepare("SELECT * FROM table1 where id IN ($mylist)"
> 
> 
> I get error : Array to string conversion...

That's because you're interpolating an array within a string, and so thearray is bing coerced to a string (giving a meaningless value).
Implode the list into a string and use that instead. For example:
$sth = $pdo->prepare("SELECT * FROM table1 where id IN (" . implode(',', $mylist) . ")";
-Tom 		 	   		  

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux