$poster=11;
$like='%key%';
$idOr='and (id=? or id=?)';
$idComma='5836, 5837, ';
$sql="SELECT id, title, contents
FROM myTable
WHERE member=? $idOr and ( title like ? or contents like ?) ";
$searchQ=$dbc-> prepare ($sql);
$searchQ->execute([$poster, 5836, 5837, $like, $like]);
The code above works fine.
I like to change the id number "5836, 5837, " to a variable named “$idComma”.
The following is one of my trials for it.
$searchQ->execute([$poster, $idComma$like, $like]);
However, the code above produces the error below.
The following is the 2nd trials of mine for it.
$searchQ->execute([$poster, $idComma $like, $like]);
However, the code above also produces the error below.
The following is the 3rd trials of mine for it.
$searchQ->execute([$poster, $idComma.$like, $like]);
However, the code above produces the Fatal error below.
How can I change the id and comma “5836, 5837,” to a variable $idComma" in the code below?
$searchQ->execute([$poster, 5836, 5837, $like, $like]);