Bonjour j'ai suivie ce tuto pour crée mon flux rss. Tout va bien jusqu'au moment ou php arrive, j'ai bien suivie mais je n'arrive pas a comprendre pourquoi cela ne marche pas.
Voici mon fichier flux_rss.php :
<?php
function &init_news_rss(&$xml_file)
{
$root = $xml_file->createElement("rss"); // création de l'élément
$root->setAttribute("version", "2.0"); // on lui ajoute un attribut
$root = $xml_file->appendChild($root); // on l'insère dans le nœud parent (ici root qui est "rss")
$channel = $xml_file->createElement("channel");
$channel = $root->appendChild($channel);
$desc = $xml_file->createElement("description");
$desc = $channel->appendChild($desc);
$text_desc = $xml_file->createTextNode("Partage de connaissances en tous genres"); // on insère du texte entre les balises <description></description>
$text_desc = $desc->appendChild($text_desc);
$link = $xml_file->createElement("link");
$link = $channel->appendChild($link);
$text_link = $xml_file->createTextNode("http://www.ehadock.fr");
$text_link = $link->appendChild($text_link);
$title = $xml_file->createElement("title");
$title = $channel->appendChild($title);
$text_title = $xml_file->createTextNode("ehadock");
$text_title = $title->appendChild($text_title);
return $channel;
}
function add_news_node(&$parent, $root, $id, $pseudo, $titre, $contenu, $date)
{
$item = $parent->createElement("item");
$item = $root->appendChild($item);
$title = $parent->createElement("title");
$title = $item->appendChild($title);
$text_title = $parent->createTextNode($titre);
$text_title = $title->appendChild($text_title);
$link = $parent->createElement("link");
$link = $item->appendChild($link);
$text_link = $parent->createTextNode("http://www.ehadock.fr/rss_news".$id.".html");
$text_link = $link->appendChild($text_link);
$desc = $parent->createElement("description");
$desc = $item->appendChild($desc);
$text_desc = $parent->createTextNode($contenu);
$text_desc = $desc->appendChild($text_desc);
$com = $parent->createElement("comments");
$com = $item->appendChild($com);
$text_com = $parent->createTextNode("http://www.ehadock.fr/news-11-".$id.".html");
$text_com = $com->appendChild($text_com);
$author = $parent->createElement("author");
$author = $item->appendChild($author);
$text_author = $parent->createTextNode($pseudo);
$text_author = $author->appendChild($text_author);
$pubdate = $parent->createElement("pubDate");
$pubdate = $item->appendChild($pubdate);
$text_date = $parent->createTextNode($date);
$text_date = $pubdate->appendChild($text_date);
$guid = $parent->createElement("guid");
$guid = $item->appendChild($guid);
$text_guid = $parent->createTextNode("http://www.ehadock.fr/rss_news".$id.".html");
$text_guid = $guid->appendChild($text_guid);
$src = $parent->createElement("source");
$src = $item->appendChild($src);
$text_src = $parent->createTextNode("http://www.ehadock.fr");
$text_src = $src->appendChild($text_src);
}
function rebuild_rss()
{
// on se connecte à la BDD
include('connexion_bd.php');
mysql_connect("$nom_du_serveur","$nom_utilisateur","$passe");
mysql_select_db("$nom_de_la_base") or die('Impossible de sélectionner une base de donnée. Assurez vous d\'avoir correctement remplit les données du fichier connexion_bd.php.');
// on récupère les news
$nws = mysql_query("SELECT id, pseudo, titre, description, datetime FROM CONTENU WHERE ORDER BY date DESC LIMIT 0 OFFSET 10");
// on crée le fichier XML
$xml_file = new DOMDocument("1.0");
// on initialise le fichier XML pour le flux RSS
$channel = init_news_rss($xml_file);
// on ajoute chaque news au fichier RSS
while($news = mysql_fetch_assoc($nws))
{
add_news_node($xml_file, $channel, $news["id"], $news["pseudo"], $news["titre"], $news["description"], date("d/m/Y H:i", $news["datetime"]));
}
// on écrit le fichier
$xml_file->save("news_FR_flux.xml");
}
?>
<?php
require('flux_rss.php');
rebuild_rss();
?>
Et voici ce qui se trouve dans mon header de index.php :
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.