IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Problème de echo RSS XML et php


Sujet :

Langage PHP

  1. #1
    Nouveau membre du Club
    Inscrit en
    Août 2009
    Messages
    45
    Détails du profil
    Informations forums :
    Inscription : Août 2009
    Messages : 45
    Points : 32
    Points
    32
    Par défaut Problème de echo RSS XML et php
    Bonjour,

    J'ai un petit souci rédactionnel avec ce code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
     
    <?php
    $dbhost = "localhost";
    $dblogi = "root";
    $dbpass = "";
    $dbbase = "mabase";
     
    $db = @mysql_connect("$dbhost", "$dblogi", "$dbpass") OR DIE("Désolé, la Base est Down !");
    @mysql_select_db("$dbbase",$db) OR DIE;
     
    $query = "SELECT clients.id, clients.pseudo, clients.descriptif, clients.date, clients.mobile, clients.num_tel, categories.nom_cat FROM clients,categories WHERE clients.categorie = categories.id ORDER BY clients.date DESC LIMIT 0,15";
    $result = mysql_query ($query) or die("La requette a échouée : ".mysql_error());
    $nb_msg = mysql_num_rows($result);
     
    header("Content-Type: text/xml");
     
    $xml = '<'.'?xml version="1.0" encoding="iso-8859-1"?'.'><rss version="2.0"><channel>';
     
    $xml .='<title>News</title>';
    $xml .='<link>http://www.monsite.com</link>';
    $xml .='<description>Les dernières annonces et modifications !</description>';
    $xml .='<managingEditor>info@monsite.com</managingEditor>';
    $xml .='<language>fr</language>';
    $xml .='<generator>monsite.com</generator>';
    $xml .='<copyright>monsite.com</copyright>';
    $xml .='<webMaster>monsite</webMaster>';
    $xml .='<image><url>http://localhost/monsite/img/logo.jpg</url><link>http://www.monsite.com</link></image>';
     
     
     
    while ($msg_data = mysql_fetch_array($result))
    {
     
     
    $dir = "clients/".$msg_data['id']."/galerie/";
    // Ouvre un dossier bien connu, et liste tous les fichiers
    if (is_dir($dir)) {
     
        if ($dh = opendir($dir)) {
    $i = 0;
            while (($file = readdir($dh)) !== false && $i < 1) {
     
            if ($file != "." && $file != ".." && $file != "Thumbs.db") {
     
    if ($file != "." && $file != ".." && $file != "Thumbs.db") 
    $img = '<![CDATA[<a title="'.$msg_data["pseudo"].'" href="http://www.monsite.com/'.$msg_data["pseudo"].'"><img border="0" width="180px" height="240px" src="http://localhost/monsite/'.$dir.$file.'" alt="'.$msg_data["pseudo"].'"/></a>]]></description>';
    $i++;
    }
        }
            closedir($dh);
        }
    }
     
    if  (($msg_data['mobile'] == "no") OR ($msg_data['mobile'] == "")) { $titre = $msg_data['pseudo']." - ".$msg_data['num_tel']; } else { $titre = $msg_data['pseudo']." - ".$msg_data['mobile']; }
     
     
    $xml .='<item>';
    $xml .='<author>'.$msg_data['pseudo'].'</author>';
    $xml .='<title>'.$titre.'</title>';
    $xml .='<link>http://www.monsite.com/'.$msg_data["pseudo"].'</link>';
    $xml .='<pubDate>'.$msg_data['date'].' GMT</pubDate>';
    $xml .='<guid>http://www.monsite.com/'.$msg_data["pseudo"].'</guid>';
     
    $xml .='<description>';
    $xml .= echo $img;
    $xml .='</description>';
     
    $xml .='<category>'.$msg_data["nom_cat"].'</category></item>';
     
    }
     
    //mysql_close();
     
    $xml .='</channel></rss>';
     
    echo $xml;
     
    ?>
    Le RSS fonctionne super mais j'aimerai afficher l'image du dossier galerie de manière dynamique...

    Tout fonctionne en dur, mais je ne sais pas comment afficher cette ligne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <![CDATA[<a title="'.$msg_data["pseudo"].'" href="http://www.monsite.com/'.$msg_data["pseudo"].'"><img border="0" width="180px" height="240px" src="http://localhost/monsite/'.$dir.$file.'" alt="'.$msg_data["pseudo"].'"/></a>]]></description>'
    entre la <description>...</description>

    je test en local alors c pour ca qu'il y a localhost, si jamais c'est normal

    D'avance merci

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    927
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 927
    Points : 2 113
    Points
    2 113
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <![CDATA[<a title="'.$msg_data["pseudo"].'" href="http://www.monsite.com/'.$msg_data["pseudo"].'"><img border="0" width="180px" height="240px" src="http://localhost/monsite/'.$dir.$file.'" alt="'.$msg_data["pseudo"].'"/></a>]]></description>'


    Je sais pas si ça aide mais est-ce que la balise description est ouverte ?
    "If you can't teach it then you don't know it."

  3. #3
    Nouveau membre du Club
    Inscrit en
    Août 2009
    Messages
    45
    Détails du profil
    Informations forums :
    Inscription : Août 2009
    Messages : 45
    Points : 32
    Points
    32
    Par défaut
    non elle est fermée...

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    927
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 927
    Points : 2 113
    Points
    2 113
    Par défaut
    Est-ce qu'elle a été ouverte avant d'être fermée ? Parce que je vois la balise de fermeture mais pas celle d'ouverture. Et plus bas tu place la ligne citée entre les balises <description> correctement ouverte et fermée.
    "If you can't teach it then you don't know it."

Discussions similaires

  1. [Configuration] problème d'echo en php
    Par Xris dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 10
    Dernier message: 24/01/2007, 15h36
  2. probléme accents dans rss xml
    Par gator dans le forum Langage
    Réponses: 6
    Dernier message: 25/07/2006, 13h36
  3. Réponses: 2
    Dernier message: 12/07/2006, 11h13
  4. PHP probleme avec flux RSS, XML
    Par sirbaldur dans le forum Langage
    Réponses: 4
    Dernier message: 06/06/2006, 15h34
  5. Problème XML/XSLT/PHP
    Par Poseidon62 dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 12/04/2006, 17h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo