1. Ce site utilise des cookies. En continuant à utiliser ce site, vous acceptez l'utilisation des cookies. En savoir plus.

Afficher une autre image

Discussion dans 'Vos demande de Code/Script pour CraftMyWebsite' créé par Mario359, 22 Octobre 2015.

MineStrator, Votre hébergeur de serveur minecraft
  1. Mario359

    Mario359 ✬ Maréchal ✬

    1 021
    144
    63
    Bonjour,
    J'aimerai un code qui permettrai d'afficher une image si l'image de base n'existe plus ou n'arrive pas à charger
    Et c'est tout
    Merci pour votre aide
     
    Dernière édition: 23 Octobre 2015
  2. Aslaak

    Aslaak Commandant

    681
    109
    43
    PHP:
    if(file_exists("url/img.png") {
    //le fichier existe
    } else {
    //le fichier n'existe pas :(
    }

    j'ai pas testé mais ça devrait marcher
     
  3. Mario359

    Mario359 ✬ Maréchal ✬

    1 021
    144
    63
    J'ai mis :
    [...]
    PHP:
                           <?php for($i 0$i count($topVoteurs) AND $i 21$i++) { ?>
                            <tr><td><?php echo $i+1 ?></td><td>
    PHP:
                            try{ ?>
                                <img src="https://avatar.yourminecraftservers.com/avatar/trnsp/not_found/tall/128/<?php echo $topVoteurs[$i]['pseudo']; ?>.png" style="height:32px; width:32px">
                            <?php } catch{ ?>
                                <img src="https://avatar.yourminecraftservers.com/avatar/trnsp/not_found/tall/128/MHF_Question.png" style="height:32px; width:32px">
                            <?php ?>
    PHP:
                           <strong><?php echo $topVoteurs[$i]['pseudo']; ?></strong></td><td><?php echo $topVoteurs[$i]['nbre_votes']; ?></td></tr>
                            <?php }?>
    [...]
    Et la page ne s'ouvre plus
    J'ai aussi fait :
    HTML:
                            if(file_exists("https://avatar.yourminecraftservers.com/avatar/trnsp/not_found/tall/128/<?php echo $topVoteurs[$i]['pseudo']; ?>.png") {
                            <img src="https://avatar.yourminecraftservers.com/avatar/trnsp/not_found/tall/128/<?php echo $topVoteurs[$i]['pseudo']; ?>.png" style="height:32px; width:32px">
                            } else {
                            <img src="https://avatar.yourminecraftservers.com/avatar/trnsp/not_found/tall/128/MHF_Question.png" style="height:32px; width:32px">
                            }
    Mais ça affiche tout en texte (le if(file_exist(etc...) et ça met les 2 images :
    if(file_exists("Merci de vous Connecter/S'inscrire pour voir les liens.") {[​IMG] } else { [​IMG] } Mario359
     
    Dernière édition: 23 Octobre 2015

Partager cette page

Chargement...