Mysql IN clause, php array
- by robert knobulous
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?