Passage d'une chaine de caractère à une requête via une fonction
Salut tout le monde,
voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11
|
function nombre_instruction($addiction,$niveau_instruction)
{
$sql_instruction = "SELECT COUNT(`p_id`) FROM `personne` WHERE `p_niveau_instruction`={$niveau_instruction} AND `{$addiction}`=1";
$res_instruction = mysql_query($sql_instruction) or die(mysql_error());
while($nombre_instruction_array = mysql_fetch_array($res_instruction))
{
$nombre_instruction = $nombre_instruction_array[0];
}
return $nombre_instruction;
} |
un appel du genre :
Code:
1 2
|
nombre_instruction('p_fumeur','secondaire'); |
génère l'erreur suivante:
Unknown column 'analphabete' in 'where clause'
Quelqu'un voit le problème?
Merci d'avance