Mysql IN clause, php array

Posted by robert knobulous on Stack Overflow See other posts from Stack Overflow or by robert knobulous
Published on 2010-03-25T17:05:29Z Indexed on 2010/03/25 17:23 UTC
Read the original article Hit count: 394

Filed under:
|
|
|

I know that this has been asked and answered before, but for the life of me I cannot find where I am going wrong. My code is below.

$backa = array("1", "7", "8", "9", "12");
$backaa = implode(",", $backa);
/* code to create connection object $wkHook */
$getOpt=$wkHook->prepare("select movementId, movementName from Movement where movementId IN ($backaa) order by movementName asc");
$getOpt->execute();
$getOpt->store_result($id, $name);

Every time I run this I get one of two errors depending upon how I use the $backaa variable. More often than not I get a call to a non-object error indicating that $getOpt is not a proper Mysql query. I have tried every fashion of quoting, bracketing, etc for the $backaa variable but it's just not working for me. What obvious thing am I missing?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql