Page 1 sur 1
Afficher image
Posté : 30 nov. 2012, 22:37
par Legendkiller06510
Bonsoir à tous,
je souhaite afficher une image dont le nom est stoqué dans ma table sql et j'execute le code suivant :
$photo = $_SESSION['photo'];
$repertoire ='/pics/' ;
echo "<br/>Photo : <img src="<?php echo $repertoire.$photo;?>" alt="" />";
Mais ça ne fonctionne pas, ça me retourne une erreur.
Pouriez vous m'éclairer svp.
Merci
Re: Afficher image
Posté : 30 nov. 2012, 22:41
par juliette
Déjà, tu met un echo dans un echo, ça ne peut pas fonctionner...
ensuite si tu ouvre un echo, le premier c'est que tu est dans php donc tu ne doit pas ré-ouvrir php
Re: Afficher image
Posté : 30 nov. 2012, 22:53
par Legendkiller06510
J'ai modifié ainsi :
$photo = $_SESSION['photo'];
$repertoire ='/pics/' ;
$res=$repertoire.$photo;
echo "<img src=$res />";
Mais ça m'affiche un petit truc et pas mon image.
Re: Afficher image
Posté : 30 nov. 2012, 22:56
par juliette
c'est un peut mieux, malgré tous, crois tu que tu peux faire comme ça ?
ta variable $res, ne devrait elle pas être concaténé ?
Re: Afficher image
Posté : 30 nov. 2012, 22:58
par Legendkiller06510
En effet, ça fonctionne mieux en la concatenant.
Merci steeve : )
Re: Afficher image
Posté : 30 nov. 2012, 23:01
par juliette
attend, parlons d'autre chose, ton dossier pics, est t'il possible que tu le change un jour ?
si il ne changeras jamais, moi j'aurais fait comme ça:
<?php
$photo = $_SESSION['photo'];
echo '<img src="/pics/'.$photo.' " />';
?>
ça fait moins de ligne; c'est plus rapide a lire, comprendre et a exécuter...