I'm trying to send a list of values and use them as column name in a sql query. However it doesn't work and I don't really know why. I enabled the php warning and the log file doesn't show any error. I tried the sql query in phpMyAdmin and it worked. Also there is no error in my jquery function which sends the array. Can anyone help me?
Here is my php file which gets the array :
$effect = $_GET['effect'];
$effectArray = rtrim(str_repeat("e.? = 't' OR ", count($effect)), "OR ");
$result = $db->prepare("
SELECT *
FROM skills s, skill_effect_types e
WHERE s.id=e.skill_id AND ($effectArray)");
$result->execute($effect);
$result->setFetchMode(PDO::FETCH_OBJ);
Here is the print_r of $result :
PDOStatement Object ( [queryString] => SELECT * FROM skills s, skill_effect_types e WHERE s.id=e.skill_id AND (e.? = 't' OR e.? = 't'))
And here is the print_r of $effect :
Array ( [0] => silence [1] => stun )