Probleme variable dans une requete

dumbae -  
 le père -
Bonjour,
$imagetrotoire = mysql_query("SELECT * FROM Annecy WHERE ID_habitat='0' AND ID_ville=Annecy'");
$tabletrotoire=mysql_fetch_assoc($imagetrotoire);

<img
 style="width: 187px; height: 140px;" alt=""
 src="<?php echo $tabletrotoire['image_habitat']; ?>">


l'image s'affiche.

$imagetrotoire = mysql_query("SELECT * FROM Annecy WHERE ID_habitat='0' AND ID_ville=$ID_ville'");
$tabletrotoire=mysql_fetch_assoc($imagetrotoire);

<img
 style="width: 187px; height: 140px;" alt=""
 src="<?php echo $tabletrotoire['image_habitat']; ?>">


l'image ne s'affiche pas.

Il y a donc un probleme avec la variable ID_ville, pouvez vous m'aider ? :/

merci

1 réponse

le père
 
Bonjour

On aura du mal si tu ne dous dit pas d'où sort ta variable ID_ville
D'autre part, il te manque un apostrophe dans tes 2 requêtes juste avant cette variable

$imagetrotoire = mysql_query("SELECT * FROM Annecy WHERE ID_habitat='0' AND ID_ville='$ID_ville'");
0